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

Commit ff3e4c83 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change Ic854f281

* changes:
  Force a re-layout of children if ListView is out of sync with the adapter in onFocusChanged. Addresses bug 2157773
parents 873c0318 c854f281
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