Lines Matching defs:direction

26  * The algorithm used for finding the next focusable view in a given direction
61 * @param direction Direction to look.
64 public final View findNextFocus(ViewGroup root, View focused, int direction) {
65 return findNextFocus(root, focused, null, direction);
73 * @param direction Direction to look.
76 public View findNextFocusFromRect(ViewGroup root, Rect focusedRect, int direction) {
78 return findNextFocus(root, null, mFocusedRect, direction);
81 private View findNextFocus(ViewGroup root, View focused, Rect focusedRect, int direction) {
84 next = findNextUserSpecifiedFocus(root, focused, direction);
92 root.addFocusables(focusables, direction);
94 next = findNextFocus(root, focused, focusedRect, direction, focusables);
102 private View findNextUserSpecifiedFocus(ViewGroup root, View focused, int direction) {
104 View userSetNextFocus = focused.findUserSetNextFocus(root, direction);
114 int direction, ArrayList<View> focusables) {
126 switch (direction) {
154 switch (direction) {
158 direction);
164 focusedRect, direction);
166 throw new IllegalArgumentException("Unknown direction: " + direction);
171 View focused, Rect focusedRect, int direction) {
181 switch (direction) {
203 Rect focusedRect, int direction) {
207 switch(direction) {
234 if (isBetterCandidate(direction, focusedRect, mOtherRect, mBestCandidateRect)) {
284 * direction from a source rect? This is the core routine that determines
286 * @param direction the direction (up, down, left, right)
292 boolean isBetterCandidate(int direction, Rect source, Rect rect1, Rect rect2) {
296 if (!isCandidate(source, rect1, direction)) {
302 if (!isCandidate(source, rect2, direction)) {
307 if (beamBeats(direction, source, rect1, rect2)) {
312 if (beamBeats(direction, source, rect2, rect1)) {
318 majorAxisDistance(direction, source, rect1),
319 minorAxisDistance(direction, source, rect1))
321 majorAxisDistance(direction, source, rect2),
322 minorAxisDistance(direction, source, rect2)));
331 boolean beamBeats(int direction, Rect source, Rect rect1, Rect rect2) {
332 final boolean rect1InSrcBeam = beamsOverlap(direction, source, rect1);
333 final boolean rect2InSrcBeam = beamsOverlap(direction, source, rect2);
342 // if rect1 is to the direction of, and rect2 is not, rect1 wins.
343 // for example, for direction left, if rect1 is to the left of the source
346 if (!isToDirectionOf(direction, source, rect2)) {
351 if ((direction == View.FOCUS_LEFT || direction == View.FOCUS_RIGHT)) {
357 // e.g for direction down, completely closer means for rect2's top
359 return (majorAxisDistance(direction, source, rect1)
360 < majorAxisDistanceToFarEdge(direction, source, rect2));
374 * Is destRect a candidate for the next focus given the direction? This
375 * checks whether the dest is at least partially to the direction of (e.g left of)
381 boolean isCandidate(Rect srcRect, Rect destRect, int direction) {
382 switch (direction) {
396 throw new IllegalArgumentException("direction must be one of "
402 * Do the "beams" w.r.t the given direction's axis of rect1 and rect2 overlap?
403 * @param direction the direction (up, down, left, right)
408 boolean beamsOverlap(int direction, Rect rect1, Rect rect2) {
409 switch (direction) {
417 throw new IllegalArgumentException("direction must be one of "
424 boolean isToDirectionOf(int direction, Rect src, Rect dest) {
425 switch (direction) {
435 throw new IllegalArgumentException("direction must be one of "
440 * @return The distance from the edge furthest in the given direction
441 * of source to the edge nearest in the given direction of dest. If the
442 * dest is not in the direction from source, return 0.
444 static int majorAxisDistance(int direction, Rect source, Rect dest) {
445 return Math.max(0, majorAxisDistanceRaw(direction, source, dest));
448 static int majorAxisDistanceRaw(int direction, Rect source, Rect dest) {
449 switch (direction) {
459 throw new IllegalArgumentException("direction must be one of "
464 * @return The distance along the major axis w.r.t the direction from the
466 * dest is not in the direction from source, return 1 (to break ties with
469 static int majorAxisDistanceToFarEdge(int direction, Rect source, Rect dest) {
470 return Math.max(1, majorAxisDistanceToFarEdgeRaw(direction, source, dest));
473 static int majorAxisDistanceToFarEdgeRaw(int direction, Rect source, Rect dest) {
474 switch (direction) {
484 throw new IllegalArgumentException("direction must be one of "
489 * Find the distance on the minor axis w.r.t the direction to the nearest
491 * @param direction the direction (up, down, left, right)
496 static int minorAxisDistance(int direction, Rect source, Rect dest) {
497 switch (direction) {
511 throw new IllegalArgumentException("direction must be one of "
521 * @param direction Direction to look
526 public View findNearestTouchable(ViewGroup root, int x, int y, int direction, int[] deltas) {
546 if (!isTouchCandidate(x, y, touchableBounds, direction)) {
552 switch (direction) {
575 switch (direction) {
597 * Is destRect a candidate for the next touch given the direction?
599 private boolean isTouchCandidate(int x, int y, Rect destRect, int direction) {
600 switch (direction) {
610 throw new IllegalArgumentException("direction must be one of "