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

Commit 135554e6 authored by Siyamed Sinir's avatar Siyamed Sinir
Browse files

AbsListView invalidates data when it isn’t changed

When setItemChecked is called for AbsListView, it does not check if the
value has changed or not. Then it invalidates the data by setting
mDataChanged to true and also requests a layout. This CL changes the
behavior and does not invalidate data or make a layout request when
the old and the new values are same.

Bug: 25793105
Change-Id: Id0e1f9d3ef348549a2aa88cf5ec9fe7a4b870f44
parent 6feab9fb
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -1036,6 +1036,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            mChoiceActionMode = startActionMode(mMultiChoiceModeCallback);
        }

        final boolean itemCheckChanged;
        if (mChoiceMode == CHOICE_MODE_MULTIPLE || mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL) {
            boolean oldValue = mCheckStates.get(position);
            mCheckStates.put(position, value);
@@ -1046,7 +1047,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                    mCheckedIdStates.delete(mAdapter.getItemId(position));
                }
            }
            if (oldValue != value) {
            itemCheckChanged = oldValue != value;
            if (itemCheckChanged) {
                if (value) {
                    mCheckedItemCount++;
                } else {
@@ -1062,6 +1064,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            boolean updateIds = mCheckedIdStates != null && mAdapter.hasStableIds();
            // Clear all values if we're checking something, or unchecking the currently
            // selected item
            itemCheckChanged = isItemChecked(position) != value;
            if (value || isItemChecked(position)) {
                mCheckStates.clear();
                if (updateIds) {
@@ -1081,8 +1084,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            }
        }

        // Do not generate a data change while we are in the layout phase
        if (!mInLayout && !mBlockLayoutRequests) {
        // Do not generate a data change while we are in the layout phase or data has not changed
        if (!mInLayout && !mBlockLayoutRequests && itemCheckChanged) {
            mDataChanged = true;
            rememberSyncState();
            requestLayout();