Lines Matching refs:direction

29  * The algorithm used for finding the next focusable view in a given direction
64 * @param direction Direction to look.
67 public final View findNextFocus(ViewGroup root, View focused, int direction) {
68 return findNextFocus(root, focused, null, direction);
76 * @param direction Direction to look.
79 public View findNextFocusFromRect(ViewGroup root, Rect focusedRect, int direction) {
81 return findNextFocus(root, null, mFocusedRect, direction);
84 private View findNextFocus(ViewGroup root, View focused, Rect focusedRect, int direction) {
87 next = findNextUserSpecifiedFocus(root, focused, direction);
95 root.addFocusables(focusables, direction);
97 next = findNextFocus(root, focused, focusedRect, direction, focusables);
105 private View findNextUserSpecifiedFocus(ViewGroup root, View focused, int direction) {
107 View userSetNextFocus = focused.findUserSetNextFocus(root, direction);
117 int direction, ArrayList<View> focusables) {
129 switch (direction) {
157 switch (direction) {
161 direction);
167 focusedRect, direction);
169 throw new IllegalArgumentException("Unknown direction: " + direction);
174 View focused, Rect focusedRect, int direction) {
186 switch (direction) {
208 Rect focusedRect, int direction) {
212 switch(direction) {
239 if (isBetterCandidate(direction, focusedRect, mOtherRect, mBestCandidateRect)) {
275 * direction from a source rect? This is the core routine that determines
277 * @param direction the direction (up, down, left, right)
283 boolean isBetterCandidate(int direction, Rect source, Rect rect1, Rect rect2) {
287 if (!isCandidate(source, rect1, direction)) {
293 if (!isCandidate(source, rect2, direction)) {
298 if (beamBeats(direction, source, rect1, rect2)) {
303 if (beamBeats(direction, source, rect2, rect1)) {
309 majorAxisDistance(direction, source, rect1),
310 minorAxisDistance(direction, source, rect1))
312 majorAxisDistance(direction, source, rect2),
313 minorAxisDistance(direction, source, rect2)));
322 boolean beamBeats(int direction, Rect source, Rect rect1, Rect rect2) {
323 final boolean rect1InSrcBeam = beamsOverlap(direction, source, rect1);
324 final boolean rect2InSrcBeam = beamsOverlap(direction, source, rect2);
333 // if rect1 is to the direction of, and rect2 is not, rect1 wins.
334 // for example, for direction left, if rect1 is to the left of the source
337 if (!isToDirectionOf(direction, source, rect2)) {
342 if ((direction == View.FOCUS_LEFT || direction == View.FOCUS_RIGHT)) {
348 // e.g for direction down, completely closer means for rect2's top
350 return (majorAxisDistance(direction, source, rect1)
351 < majorAxisDistanceToFarEdge(direction, source, rect2));
365 * Is destRect a candidate for the next focus given the direction? This
366 * checks whether the dest is at least partially to the direction of (e.g left of)
372 boolean isCandidate(Rect srcRect, Rect destRect, int direction) {
373 switch (direction) {
387 throw new IllegalArgumentException("direction must be one of "
393 * Do the "beams" w.r.t the given direction's axis of rect1 and rect2 overlap?
394 * @param direction the direction (up, down, left, right)
399 boolean beamsOverlap(int direction, Rect rect1, Rect rect2) {
400 switch (direction) {
408 throw new IllegalArgumentException("direction must be one of "
415 boolean isToDirectionOf(int direction, Rect src, Rect dest) {
416 switch (direction) {
426 throw new IllegalArgumentException("direction must be one of "
431 * @return The distance from the edge furthest in the given direction
432 * of source to the edge nearest in the given direction of dest. If the
433 * dest is not in the direction from source, return 0.
435 static int majorAxisDistance(int direction, Rect source, Rect dest) {
436 return Math.max(0, majorAxisDistanceRaw(direction, source, dest));
439 static int majorAxisDistanceRaw(int direction, Rect source, Rect dest) {
440 switch (direction) {
450 throw new IllegalArgumentException("direction must be one of "
455 * @return The distance along the major axis w.r.t the direction from the
457 * dest is not in the direction from source, return 1 (to break ties with
460 static int majorAxisDistanceToFarEdge(int direction, Rect source, Rect dest) {
461 return Math.max(1, majorAxisDistanceToFarEdgeRaw(direction, source, dest));
464 static int majorAxisDistanceToFarEdgeRaw(int direction, Rect source, Rect dest) {
465 switch (direction) {
475 throw new IllegalArgumentException("direction must be one of "
480 * Find the distance on the minor axis w.r.t the direction to the nearest
482 * @param direction the direction (up, down, left, right)
487 static int minorAxisDistance(int direction, Rect source, Rect dest) {
488 switch (direction) {
502 throw new IllegalArgumentException("direction must be one of "
512 * @param direction Direction to look
517 public View findNearestTouchable(ViewGroup root, int x, int y, int direction, int[] deltas) {
537 if (!isTouchCandidate(x, y, touchableBounds, direction)) {
543 switch (direction) {
566 switch (direction) {
588 * Is destRect a candidate for the next touch given the direction?
590 private boolean isTouchCandidate(int x, int y, Rect destRect, int direction) {
591 switch (direction) {
601 throw new IllegalArgumentException("direction must be one of "