Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30f2b4af authored by Yabin Huang's avatar Yabin Huang Committed by Automerger Merge Worker
Browse files

Update FocusFinder am: 713af5fd am: 74f91531

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

Change-Id: I82c7e5dd78281e2c49f31063c3979845cef9831b
parents dd8efac0 74f91531
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -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,30 +376,30 @@ 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;
    }

    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;
    }

    private static View getNextKeyboardNavigationCluster(
            View root,