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

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

Merge "Fix another issue that DocUI may not refresh on content change." into nyc-andromeda-dev

parents e2cd3cca f7df715e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

package com.android.documentsui;

import static com.android.documentsui.base.Shared.DEBUG;

import android.annotation.MainThread;
import android.annotation.Nullable;
import android.util.Log;

import com.android.documentsui.base.Shared;
import com.android.documentsui.selection.BandController;
@@ -27,6 +30,8 @@ import com.android.documentsui.selection.BandController;
 * while Band Selection is active.
 */
public final class DirectoryReloadLock {
    private static final String TAG = "DirectoryReloadLock";

    private int mPauseCount = 0;
    private @Nullable Runnable mCallback;

@@ -37,6 +42,7 @@ public final class DirectoryReloadLock {
    public void block() {
        Shared.checkMainLoop();
        mPauseCount++;
        if (DEBUG) Log.v(TAG, "Block count increments to " + mPauseCount + ".");
    }

    /**
@@ -48,6 +54,7 @@ public final class DirectoryReloadLock {
        Shared.checkMainLoop();
        assert(mPauseCount > 0);
        mPauseCount--;
        if (DEBUG) Log.v(TAG, "Block count decrements to " + mPauseCount + ".");
        if (mPauseCount == 0 && mCallback != null) {
            mCallback.run();
            mCallback = null;
+27 −16
Original line number Diff line number Diff line
@@ -128,10 +128,6 @@ public final class GestureSelector {
            handled = handleInterceptedDownEvent(e);
        }

        if (e.isActionUp()) {
            handled = handleUpEvent(e);
        }

        if (e.isActionMove()) {
            handled = handleInterceptedMoveEvent(e);
        }
@@ -148,6 +144,10 @@ public final class GestureSelector {
            handleUpEvent(e);
        }

        if (e.isActionCancel()) {
            handleCancelEvent(e);
        }

        if (e.isActionMove()) {
            handleOnTouchMoveEvent(rv, e);
        }
@@ -175,17 +175,28 @@ public final class GestureSelector {
        return false;
    }

    // Called when ACTION_UP event is intercepted.
    // Essentially, since this means all gesture movement is over, reset everything.
    private boolean handleUpEvent(InputEvent e) {
    // Called when ACTION_UP event is to be handled.
    // Essentially, since this means all gesture movement is over, reset everything and apply
    // provisional selection.
    private void handleUpEvent(InputEvent e) {
        mSelectionMgr.getSelection().applyProvisionalSelection();
        endSelection();
    }

    // Called when ACTION_CANCEL event is to be handled.
    // This means this gesture selection is aborted, so reset everything and abandon provisional
    // selection.
    private void handleCancelEvent(InputEvent e) {
        mSelectionMgr.cancelProvisionalSelection();
        endSelection();
    }

    private void endSelection() {
        assert(mStarted);
        mLastStartedItemPos = -1;
        if (mStarted) {
        mStarted = false;
            mSelectionMgr.getSelection().applyProvisionalSelection();
        mLock.unblock();
    }
        return false;
    }

    // Call when an intercepted ACTION_MOVE event is passed down.
    // At this point, we are sure user wants to gesture multi-select.
+8 −1
Original line number Diff line number Diff line
@@ -322,6 +322,13 @@ public final class SelectionManager {
        notifySelectionChanged();
    }

    void cancelProvisionalSelection() {
        for (String id : mSelection.mProvisionalSelection) {
            notifyItemStateChanged(id, false);
        }
        mSelection.cancelProvisionalSelection();
    }

    /**
     * Stops an in-progress range selection. All selection done with
     * {@link #snapRangeSelection(int, int)} with type RANGE_PROVISIONAL will be lost if
@@ -330,7 +337,7 @@ public final class SelectionManager {
    public void endRangeSelection() {
        mRanger = null;
        // Clean up in case there was any leftover provisional selection
        mSelection.cancelProvisionalSelection();
        cancelProvisionalSelection();
    }

    /**