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

Commit 99441c45 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #3149290: java.lang.RuntimeException: Unable to pause activity

{com.android.settings/com.android.settings.applications.StorageUse}

AbsListView could call mAdapter.getItemId() if a save state happened
after the data changed but before a layout occurred.

Change-Id: Ica020971dc458dff79b56dd810733e217f4f7da6
parent 2bd83c00
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -963,7 +963,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te

        SavedState ss = new SavedState(superState);

        boolean haveChildren = getChildCount() > 0;
        boolean haveChildren = getChildCount() > 0 && mItemCount > 0;
        long selectedId = getSelectedItemId();
        ss.selectedId = selectedId;
        ss.height = getHeight();
@@ -978,8 +978,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                // Remember the position of the first child
                View v = getChildAt(0);
                ss.viewTop = v.getTop();
                ss.position = mFirstPosition;
                ss.firstId = mAdapter.getItemId(mFirstPosition);
                int firstPos = mFirstPosition;
                if (firstPos >= mItemCount) {
                    firstPos = mItemCount - 1;
                }
                ss.position = firstPos;
                ss.firstId = mAdapter.getItemId(firstPos);
            } else {
                ss.viewTop = 0;
                ss.firstId = INVALID_POSITION;