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

Commit fa74c771 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix state of file context menu when state changes while already selected" into arc-apps

parents 3ef1a20c ee9d85ca
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);