@@ -62,7 +62,7 @@ private FocusFinder() {}
6262 * @return The next focusable view, or null if none exists.
6363 */
6464 public final View findNextFocus (ViewGroup root , View focused , int direction ) {
65- return findNextFocus (root , focused , mFocusedRect , direction );
65+ return findNextFocus (root , focused , null , direction );
6666 }
6767
6868 /**
@@ -122,34 +122,40 @@ private View findNextFocus(ViewGroup root, View focused, Rect focusedRect,
122122 int direction , ArrayList <View > focusables ) {
123123 final int directionMasked = (direction & ~View .FOCUS_ACCESSIBILITY );
124124 if (focused != null ) {
125+ if (focusedRect == null ) {
126+ focusedRect = mFocusedRect ;
127+ }
125128 // fill in interesting rect from focused
126129 focused .getFocusedRect (focusedRect );
127130 root .offsetDescendantRectToMyCoords (focused , focusedRect );
128131 } else {
129- // make up a rect at top left or bottom right of root
130- switch (directionMasked ) {
131- case View .FOCUS_RIGHT :
132- case View .FOCUS_DOWN :
133- setFocusTopLeft (root , focusedRect );
134- break ;
135- case View .FOCUS_FORWARD :
136- if (root .isLayoutRtl ()) {
137- setFocusBottomRight (root , focusedRect );
138- } else {
139- setFocusTopLeft (root , focusedRect );
140- }
141- break ;
142-
143- case View .FOCUS_LEFT :
144- case View .FOCUS_UP :
145- setFocusBottomRight (root , focusedRect );
146- break ;
147- case View .FOCUS_BACKWARD :
148- if (root .isLayoutRtl ()) {
132+ if (focusedRect == null ) {
133+ focusedRect = mFocusedRect ;
134+ // make up a rect at top left or bottom right of root
135+ switch (directionMasked ) {
136+ case View .FOCUS_RIGHT :
137+ case View .FOCUS_DOWN :
149138 setFocusTopLeft (root , focusedRect );
150- } else {
139+ break ;
140+ case View .FOCUS_FORWARD :
141+ if (root .isLayoutRtl ()) {
142+ setFocusBottomRight (root , focusedRect );
143+ } else {
144+ setFocusTopLeft (root , focusedRect );
145+ }
146+ break ;
147+
148+ case View .FOCUS_LEFT :
149+ case View .FOCUS_UP :
151150 setFocusBottomRight (root , focusedRect );
152- break ;
151+ break ;
152+ case View .FOCUS_BACKWARD :
153+ if (root .isLayoutRtl ()) {
154+ setFocusTopLeft (root , focusedRect );
155+ } else {
156+ setFocusBottomRight (root , focusedRect );
157+ break ;
158+ }
153159 }
154160 }
155161 }
0 commit comments