Lines Matching refs: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) {
182 switch (direction) {
204 Rect focusedRect, int direction) {
208 switch(direction) {
235 if (isBetterCandidate(direction, focusedRect, mOtherRect, mBestCandidateRect)) {
271 * direction from a source rect? This is the core routine that determines
273 * @param direction the direction (up, down, left, right)
279 boolean isBetterCandidate(int direction, Rect source, Rect rect1, Rect rect2) {
283 if (!isCandidate(source, rect1, direction)) {
289 if (!isCandidate(source, rect2, direction)) {
294 if (beamBeats(direction, source, rect1, rect2)) {
299 if (beamBeats(direction, source, rect2, rect1)) {
305 majorAxisDistance(direction, source, rect1),
306 minorAxisDistance(direction, source, rect1))
308 majorAxisDistance(direction, source, rect2),
309 minorAxisDistance(direction, source, rect2)));
318 boolean beamBeats(int direction, Rect source, Rect rect1, Rect rect2) {
319 final boolean rect1InSrcBeam = beamsOverlap(direction, source, rect1);
320 final boolean rect2InSrcBeam = beamsOverlap(direction, source, rect2);
329 // if rect1 is to the direction of, and rect2 is not, rect1 wins.
330 // for example, for direction left, if rect1 is to the left of the source
333 if (!isToDirectionOf(direction, source, rect2)) {
338 if ((direction == View.FOCUS_LEFT || direction == View.FOCUS_RIGHT)) {
344 // e.g for direction down, completely closer means for rect2's top
346 return (majorAxisDistance(direction, source, rect1)
347 < majorAxisDistanceToFarEdge(direction, source, rect2));
361 * Is destRect a candidate for the next focus given the direction? This
362 * checks whether the dest is at least partially to the direction of (e.g left of)
368 boolean isCandidate(Rect srcRect, Rect destRect, int direction) {
369 switch (direction) {
383 throw new IllegalArgumentException("direction must be one of "
389 * Do the "beams" w.r.t the given direction's axis of rect1 and rect2 overlap?
390 * @param direction the direction (up, down, left, right)
395 boolean beamsOverlap(int direction, Rect rect1, Rect rect2) {
396 switch (direction) {
404 throw new IllegalArgumentException("direction must be one of "
411 boolean isToDirectionOf(int direction, Rect src, Rect dest) {
412 switch (direction) {
422 throw new IllegalArgumentException("direction must be one of "
427 * @return The distance from the edge furthest in the given direction
428 * of source to the edge nearest in the given direction of dest. If the
429 * dest is not in the direction from source, return 0.
431 static int majorAxisDistance(int direction, Rect source, Rect dest) {
432 return Math.max(0, majorAxisDistanceRaw(direction, source, dest));
435 static int majorAxisDistanceRaw(int direction, Rect source, Rect dest) {
436 switch (direction) {
446 throw new IllegalArgumentException("direction must be one of "
451 * @return The distance along the major axis w.r.t the direction from the
453 * dest is not in the direction from source, return 1 (to break ties with
456 static int majorAxisDistanceToFarEdge(int direction, Rect source, Rect dest) {
457 return Math.max(1, majorAxisDistanceToFarEdgeRaw(direction, source, dest));
460 static int majorAxisDistanceToFarEdgeRaw(int direction, Rect source, Rect dest) {
461 switch (direction) {
471 throw new IllegalArgumentException("direction must be one of "
476 * Find the distance on the minor axis w.r.t the direction to the nearest
478 * @param direction the direction (up, down, left, right)
483 static int minorAxisDistance(int direction, Rect source, Rect dest) {
484 switch (direction) {
498 throw new IllegalArgumentException("direction must be one of "
508 * @param direction Direction to look
513 public View findNearestTouchable(ViewGroup root, int x, int y, int direction, int[] deltas) {
533 if (!isTouchCandidate(x, y, touchableBounds, direction)) {
539 switch (direction) {
562 switch (direction) {
584 * Is destRect a candidate for the next touch given the direction?
586 private boolean isTouchCandidate(int x, int y, Rect destRect, int direction) {
587 switch (direction) {
597 throw new IllegalArgumentException("direction must be one of "