OSDN Git Service

Merge "Don't focus search user-specified views which are invisible" into oc-dev
authorEvan Rosky <erosky@google.com>
Tue, 2 May 2017 20:54:00 +0000 (20:54 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Tue, 2 May 2017 20:54:12 +0000 (20:54 +0000)
core/java/android/view/FocusFinder.java

index 1ccf16a..48e5ca9 100644 (file)
@@ -193,10 +193,14 @@ public class FocusFinder {
     private View findNextUserSpecifiedFocus(ViewGroup root, View focused, int direction) {
         // check for user specified next focus
         View userSetNextFocus = focused.findUserSetNextFocus(root, direction);
-        if (userSetNextFocus != null && userSetNextFocus.isFocusable()
-                && (!userSetNextFocus.isInTouchMode()
-                        || userSetNextFocus.isFocusableInTouchMode())) {
-            return userSetNextFocus;
+        while (userSetNextFocus != null) {
+            if (userSetNextFocus.isFocusable()
+                    && userSetNextFocus.getVisibility() == View.VISIBLE
+                    && (!userSetNextFocus.isInTouchMode()
+                            || userSetNextFocus.isFocusableInTouchMode())) {
+                return userSetNextFocus;
+            }
+            userSetNextFocus = userSetNextFocus.findUserSetNextFocus(root, direction);
         }
         return null;
     }