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

Commit 6a0d0994 authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 2964954 - Lists blow up if their adapter changes while detached.

If a list adapter's content changes while the ListView is detached
from a window, the data change is not registered and the next
layoutChildren call causes the ListView to detect a bad change that
the adapter did not notify ListView about. Any time a ListView becomes
attached to a window, has a valid adapter, and no attached data set
observer, treat it as a data set changed event.

Change-Id: Ic00c05a1a0d063399dc78d5d877e3d5f9b1bee16
parent aa6110d8
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1988,6 +1988,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        if (mAdapter != null && mDataSetObserver == null) {
            mDataSetObserver = new AdapterDataSetObserver();
            mAdapter.registerDataSetObserver(mDataSetObserver);

            // Data may have changed while we were detached. Refresh.
            mDataChanged = true;
            mOldItemCount = mItemCount;
            mItemCount = mAdapter.getCount();
        }
    }