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

Commit 7b8dfeb6 authored by Adam Powell's avatar Adam Powell Committed by Android Git Automerger
Browse files

am 86a1a245: Merge "Revert "Revert "Fix ListView is not scrolled properly with...

am 86a1a245: Merge "Revert "Revert "Fix ListView is not scrolled properly with arrows""" into jb-mr2-dev

* commit '86a1a245':
  Revert "Revert "Fix ListView is not scrolled properly with arrows""
parents 61b19ea1 86a1a245
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -2431,7 +2431,9 @@ public class ListView extends AbsListView {
        View selectedView = getSelectedView();
        int selectedPos = mSelectedPosition;

        int nextSelectedPosition = lookForSelectablePositionOnScreen(direction);
        int nextSelectedPosition = (direction == View.FOCUS_DOWN) ?
                lookForSelectablePosition(selectedPos + 1, true) :
                lookForSelectablePosition(selectedPos - 1, false);
        int amountToScroll = amountToScroll(direction, nextSelectedPosition);

        // if we are moving focus, we may OVERRIDE the default behavior
@@ -2643,14 +2645,18 @@ public class ListView extends AbsListView {
        final int listBottom = getHeight() - mListPadding.bottom;
        final int listTop = mListPadding.top;

        final int numChildren = getChildCount();
        int numChildren = getChildCount();

        if (direction == View.FOCUS_DOWN) {
            int indexToMakeVisible = numChildren - 1;
            if (nextSelectedPosition != INVALID_POSITION) {
                indexToMakeVisible = nextSelectedPosition - mFirstPosition;
            }

            while (numChildren <= indexToMakeVisible) {
                // Child to view is not attached yet.
                addViewBelow(getChildAt(numChildren - 1), mFirstPosition + numChildren - 1);
                numChildren++;
            }
            final int positionToMakeVisible = mFirstPosition + indexToMakeVisible;
            final View viewToMakeVisible = getChildAt(indexToMakeVisible);

@@ -2684,6 +2690,12 @@ public class ListView extends AbsListView {
            if (nextSelectedPosition != INVALID_POSITION) {
                indexToMakeVisible = nextSelectedPosition - mFirstPosition;
            }
            while (indexToMakeVisible < 0) {
                // Child to view is not attached yet.
                addViewAbove(getChildAt(0), mFirstPosition);
                mFirstPosition--;
                indexToMakeVisible = nextSelectedPosition - mFirstPosition;
            }
            final int positionToMakeVisible = mFirstPosition + indexToMakeVisible;
            final View viewToMakeVisible = getChildAt(indexToMakeVisible);
            int goalTop = listTop;