Loading src/com/android/documentsui/DirectoryReloadLock.java +7 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -37,6 +42,7 @@ public final class DirectoryReloadLock { public void block() { Shared.checkMainLoop(); mPauseCount++; if (DEBUG) Log.v(TAG, "Block count increments to " + mPauseCount + "."); } /** Loading @@ -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; Loading src/com/android/documentsui/selection/GestureSelector.java +27 −16 Original line number Diff line number Diff line Loading @@ -128,10 +128,6 @@ public final class GestureSelector { handled = handleInterceptedDownEvent(e); } if (e.isActionUp()) { handled = handleUpEvent(e); } if (e.isActionMove()) { handled = handleInterceptedMoveEvent(e); } Loading @@ -148,6 +144,10 @@ public final class GestureSelector { handleUpEvent(e); } if (e.isActionCancel()) { handleCancelEvent(e); } if (e.isActionMove()) { handleOnTouchMoveEvent(rv, e); } Loading Loading @@ -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. Loading src/com/android/documentsui/selection/SelectionManager.java +8 −1 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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(); } /** Loading Loading
src/com/android/documentsui/DirectoryReloadLock.java +7 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -37,6 +42,7 @@ public final class DirectoryReloadLock { public void block() { Shared.checkMainLoop(); mPauseCount++; if (DEBUG) Log.v(TAG, "Block count increments to " + mPauseCount + "."); } /** Loading @@ -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; Loading
src/com/android/documentsui/selection/GestureSelector.java +27 −16 Original line number Diff line number Diff line Loading @@ -128,10 +128,6 @@ public final class GestureSelector { handled = handleInterceptedDownEvent(e); } if (e.isActionUp()) { handled = handleUpEvent(e); } if (e.isActionMove()) { handled = handleInterceptedMoveEvent(e); } Loading @@ -148,6 +144,10 @@ public final class GestureSelector { handleUpEvent(e); } if (e.isActionCancel()) { handleCancelEvent(e); } if (e.isActionMove()) { handleOnTouchMoveEvent(rv, e); } Loading Loading @@ -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. Loading
src/com/android/documentsui/selection/SelectionManager.java +8 −1 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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(); } /** Loading