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

Commit c854f281 authored by Adam Powell's avatar Adam Powell
Browse files

Force a re-layout of children if ListView is out of sync with the

adapter in onFocusChanged. Addresses bug 2157773
parent 83e10959
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -3080,13 +3080,19 @@ public class ListView extends AbsListView {
        if (gainFocus && previouslyFocusedRect != null) {
            previouslyFocusedRect.offset(mScrollX, mScrollY);

            final ListAdapter adapter = mAdapter;
            final int firstPosition = mFirstPosition;
            // Don't cache the result of getChildCount here, it could change in layoutChildren.
            if (adapter.getCount() < getChildCount() + firstPosition) {
                mLayoutMode = LAYOUT_NORMAL;
                layoutChildren();
            }

            // figure out which item should be selected based on previously
            // focused rect
            Rect otherRect = mTempRect;
            int minDistance = Integer.MAX_VALUE;
            final int childCount = getChildCount();
            final int firstPosition = mFirstPosition;
            final ListAdapter adapter = mAdapter;

            for (int i = 0; i < childCount; i++) {
                // only consider selectable views