Merge "Update FocusFinder" into rvc-qpr-dev am: 5b88562f8c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12228031 Change-Id: I76c548a63aba55e34601fec2a2a0ed8c44ef7a19
This commit is contained in:
@@ -311,6 +311,9 @@ public class FocusFinder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final int count = focusables.size();
|
final int count = focusables.size();
|
||||||
|
if (count < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case View.FOCUS_FORWARD:
|
case View.FOCUS_FORWARD:
|
||||||
return getNextFocusable(focused, focusables, count);
|
return getNextFocusable(focused, focusables, count);
|
||||||
@@ -373,29 +376,29 @@ public class FocusFinder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static View getNextFocusable(View focused, ArrayList<View> focusables, int count) {
|
private static View getNextFocusable(View focused, ArrayList<View> focusables, int count) {
|
||||||
|
if (count < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (focused != null) {
|
if (focused != null) {
|
||||||
int position = focusables.lastIndexOf(focused);
|
int position = focusables.lastIndexOf(focused);
|
||||||
if (position >= 0 && position + 1 < count) {
|
if (position >= 0 && position + 1 < count) {
|
||||||
return focusables.get(position + 1);
|
return focusables.get(position + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!focusables.isEmpty()) {
|
return focusables.get(0);
|
||||||
return focusables.get(0);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static View getPreviousFocusable(View focused, ArrayList<View> focusables, int count) {
|
private static View getPreviousFocusable(View focused, ArrayList<View> focusables, int count) {
|
||||||
|
if (count < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (focused != null) {
|
if (focused != null) {
|
||||||
int position = focusables.indexOf(focused);
|
int position = focusables.indexOf(focused);
|
||||||
if (position > 0) {
|
if (position > 0) {
|
||||||
return focusables.get(position - 1);
|
return focusables.get(position - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!focusables.isEmpty()) {
|
return focusables.get(count - 1);
|
||||||
return focusables.get(count - 1);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static View getNextKeyboardNavigationCluster(
|
private static View getNextKeyboardNavigationCluster(
|
||||||
|
|||||||
Reference in New Issue
Block a user