FairEmail/recyclerview-selection.patch

49 lines
2.5 KiB
Diff
Raw Normal View History

diff --git a/app/src/main/java/androidx/recyclerview/selection/GestureSelectionHelper.java b/app/src/main/java/androidx/recyclerview/selection/GestureSelectionHelper.java
index 7f2a5bb2..3736ada4 100644
--- a/app/src/main/java/androidx/recyclerview/selection/GestureSelectionHelper.java
+++ b/app/src/main/java/androidx/recyclerview/selection/GestureSelectionHelper.java
@@ -98,7 +98,7 @@ final class GestureSelectionHelper implements OnItemTouchListener {
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
- return mStarted;
+ return mStarted && mSelectionMgr.isRangeActive();
default:
return false;
}
2019-05-09 13:12:47 +00:00
diff --git a/app/src/main/java/androidx/recyclerview/selection/SelectionTracker.java b/app/src/main/java/androidx/recyclerview/selection/SelectionTracker.java
index ae3785df..1591ff4b 100644
--- a/app/src/main/java/androidx/recyclerview/selection/SelectionTracker.java
+++ b/app/src/main/java/androidx/recyclerview/selection/SelectionTracker.java
@@ -765,7 +765,13 @@ public abstract class SelectionTracker<K> {
new Runnable() {
@Override
public void run() {
- gestureHelper.start();
+ if (mSelectionPredicate.canSelectMultiple()) {
+ try {
+ gestureHelper.start();
+ } catch (IllegalStateException ex) {
+ ex.printStackTrace();
+ }
+ }
}
},
mOnDragInitiatedListener,
diff --git a/app/src/main/java/androidx/recyclerview/selection/TouchInputHandler.java b/app/src/main/java/androidx/recyclerview/selection/TouchInputHandler.java
index d82812cc..48db78ec 100644
--- a/app/src/main/java/androidx/recyclerview/selection/TouchInputHandler.java
+++ b/app/src/main/java/androidx/recyclerview/selection/TouchInputHandler.java
@@ -107,6 +107,11 @@ final class TouchInputHandler<K> extends MotionInputHandler<K> {
}
@Override
+ public boolean onDoubleTapEvent(MotionEvent e) {
+ return mSelectionTracker.hasSelection();
+ }
+
+ @Override
public void onLongPress(@NonNull MotionEvent e) {
if (!mDetailsLookup.overItemWithSelectionKey(e)) {
if (DEBUG) Log.d(TAG, "Ignoring LongPress on non-model-backed item.");