Update FocusFinder am: 713af5fdd3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11825630

Change-Id: I7636504c50fa48e92e89f557461a35bd0aea015a
This commit is contained in:
Yabin Huang
2020-06-16 17:41:50 +00:00
committed by Automerger Merge Worker

View File

@@ -311,6 +311,9 @@ public class FocusFinder {
}
final int count = focusables.size();
if (count < 2) {
return null;
}
switch (direction) {
case View.FOCUS_FORWARD:
return getNextFocusable(focused, focusables, count);
@@ -373,29 +376,29 @@ public class FocusFinder {
}
private static View getNextFocusable(View focused, ArrayList<View> focusables, int count) {
if (count < 2) {
return null;
}
if (focused != null) {
int position = focusables.lastIndexOf(focused);
if (position >= 0 && position + 1 < count) {
return focusables.get(position + 1);
}
}
if (!focusables.isEmpty()) {
return focusables.get(0);
}
return null;
return focusables.get(0);
}
private static View getPreviousFocusable(View focused, ArrayList<View> focusables, int count) {
if (count < 2) {
return null;
}
if (focused != null) {
int position = focusables.indexOf(focused);
if (position > 0) {
return focusables.get(position - 1);
}
}
if (!focusables.isEmpty()) {
return focusables.get(count - 1);
}
return null;
return focusables.get(count - 1);
}
private static View getNextKeyboardNavigationCluster(