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

Commit ee9d85ca authored by Jon Mann's avatar Jon Mann Committed by Garfield Tan
Browse files

Fix state of file context menu when state changes while already

selected

Test: N/A
Bug: 32516903
Change-Id: I4fa6fa47d3c230618e233492db77f58c170629c6
parent 0f7e5878
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@ public final class SelectionManager {
                // Update the selection to remove any disappeared IDs.
                mSelection.cancelProvisionalSelection();
                mSelection.intersect(mModelIds);

                notifyDataChanged();
            }

            @Override
@@ -423,6 +425,19 @@ public final class SelectionManager {
        return mCanSetState.test(id, nextState);
    }

    private void notifyDataChanged() {
        int lastListener = mItemCallbacks.size() - 1;
        for (String id : mSelection) {
            if (!canSetState(id, true)) {
                attemptDeselect(id);
            } else {
                for (int i = lastListener; i >= 0; i--) {
                    mItemCallbacks.get(i).onItemStateChanged(id, true);
                }
            }
        }
    }

    /**
     * Notifies registered listeners when the selection status of a single item
     * (identified by {@code position}) changes.
+9 −0
Original line number Diff line number Diff line
@@ -58,6 +58,15 @@ public class SelectionMetadata
        mDocFinder = docFinder;
    }

    public void reset(){
        mFileCount = 0;
        mDirectoryCount = 0;
        mPartialCount = 0;
        mWritableDirectoryCount = 0;
        mNoDeleteCount = 0;
        mNoRenameCount = 0;
    }

    @Override
    public void onItemStateChanged(String modelId, boolean selected) {
        final Cursor cursor = mDocFinder.apply(modelId);