Lines Matching refs:direction

26  * The algorithm used for finding the next focusable view in a given direction
59 * @param direction Direction to look.
62 public final View findNextFocus(ViewGroup root, View focused, int direction) {
66 View userSetNextFocus = focused.findUserSetNextFocus(root, direction);
79 switch (direction) {
98 return findNextFocus(root, focused, mFocusedRect, direction);
106 * @param direction Direction to look.
109 public View findNextFocusFromRect(ViewGroup root, Rect focusedRect, int direction) {
110 return findNextFocus(root, null, focusedRect, direction);
113 private View findNextFocus(ViewGroup root, View focused, Rect focusedRect, int direction) {
114 ArrayList<View> focusables = root.getFocusables(direction);
120 if (direction == View.FOCUS_FORWARD || direction == View.FOCUS_BACKWARD) {
136 switch (direction) {
161 switch(direction) {
188 if (isBetterCandidate(direction, focusedRect, mOtherRect, mBestCandidateRect)) {
198 * direction from a source rect? This is the core routine that determines
200 * @param direction the direction (up, down, left, right)
206 boolean isBetterCandidate(int direction, Rect source, Rect rect1, Rect rect2) {
210 if (!isCandidate(source, rect1, direction)) {
216 if (!isCandidate(source, rect2, direction)) {
221 if (beamBeats(direction, source, rect1, rect2)) {
226 if (beamBeats(direction, source, rect2, rect1)) {
232 majorAxisDistance(direction, source, rect1),
233 minorAxisDistance(direction, source, rect1))
235 majorAxisDistance(direction, source, rect2),
236 minorAxisDistance(direction, source, rect2)));
245 boolean beamBeats(int direction, Rect source, Rect rect1, Rect rect2) {
246 final boolean rect1InSrcBeam = beamsOverlap(direction, source, rect1);
247 final boolean rect2InSrcBeam = beamsOverlap(direction, source, rect2);
256 // if rect1 is to the direction of, and rect2 is not, rect1 wins.
257 // for example, for direction left, if rect1 is to the left of the source
260 if (!isToDirectionOf(direction, source, rect2)) {
265 if ((direction == View.FOCUS_LEFT || direction == View.FOCUS_RIGHT)) {
271 // e.g for direction down, completely closer means for rect2's top
273 return (majorAxisDistance(direction, source, rect1)
274 < majorAxisDistanceToFarEdge(direction, source, rect2));
288 * Is destRect a candidate for the next focus given the direction? This
289 * checks whether the dest is at least partially to the direction of (e.g left of)
295 boolean isCandidate(Rect srcRect, Rect destRect, int direction) {
296 switch (direction) {
310 throw new IllegalArgumentException("direction must be one of "
317 * @param direction the direction (up, down, left, right)
322 boolean beamsOverlap(int direction, Rect rect1, Rect rect2) {
323 switch (direction) {
331 throw new IllegalArgumentException("direction must be one of "
338 boolean isToDirectionOf(int direction, Rect src, Rect dest) {
339 switch (direction) {
349 throw new IllegalArgumentException("direction must be one of "
354 * @return The distance from the edge furthest in the given direction
355 * of source to the edge nearest in the given direction of dest. If the
356 * dest is not in the direction from source, return 0.
358 static int majorAxisDistance(int direction, Rect source, Rect dest) {
359 return Math.max(0, majorAxisDistanceRaw(direction, source, dest));
362 static int majorAxisDistanceRaw(int direction, Rect source, Rect dest) {
363 switch (direction) {
373 throw new IllegalArgumentException("direction must be one of "
378 * @return The distance along the major axis w.r.t the direction from the
380 * dest is not in the direction from source, return 1 (to break ties with
383 static int majorAxisDistanceToFarEdge(int direction, Rect source, Rect dest) {
384 return Math.max(1, majorAxisDistanceToFarEdgeRaw(direction, source, dest));
387 static int majorAxisDistanceToFarEdgeRaw(int direction, Rect source, Rect dest) {
388 switch (direction) {
398 throw new IllegalArgumentException("direction must be one of "
403 * Find the distance on the minor axis w.r.t the direction to the nearest
405 * @param direction the direction (up, down, left, right)
410 static int minorAxisDistance(int direction, Rect source, Rect dest) {
411 switch (direction) {
425 throw new IllegalArgumentException("direction must be one of "
435 * @param direction Direction to look
440 public View findNearestTouchable(ViewGroup root, int x, int y, int direction, int[] deltas) {
460 if (!isTouchCandidate(x, y, touchableBounds, direction)) {
466 switch (direction) {
489 switch (direction) {
511 * Is destRect a candidate for the next touch given the direction?
513 private boolean isTouchCandidate(int x, int y, Rect destRect, int direction) {
514 switch (direction) {
524 throw new IllegalArgumentException("direction must be one of "