1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-22 15:55:57 +00:00

Updated recyclerview-selection patch

This commit is contained in:
M66B 2020-05-18 16:28:58 +02:00
parent 351f931d8f
commit d99d8d84aa
2 changed files with 59 additions and 78 deletions

View file

@ -1,8 +1,61 @@
diff --git a/app/src/main/java/androidx/recyclerview/selection/SelectionTracker.java b/app/src/main/java/androidx/recyclerview/selection/SelectionTracker.java diff -rupN /home/marcel/support/recyclerview/recyclerview-selection/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java
index 50cc4ceb7..910935a0a 100644 --- /home/marcel/support/recyclerview/recyclerview-selection/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java 2020-03-23 17:03:46.043122318 +0100
--- a/app/src/main/java/androidx/recyclerview/selection/SelectionTracker.java +++ app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java 2020-04-24 21:08:55.542011257 +0200
+++ b/app/src/main/java/androidx/recyclerview/selection/SelectionTracker.java @@ -379,6 +379,10 @@ public class DefaultSelectionTracker<K>
@@ -503,7 +503,7 @@ public abstract class SelectionTracker<K> { return mRange != null;
}
+ boolean isOverlapping(int position, int count) {
+ return (mRange != null && mRange.isOverlapping(position, count));
+ }
+
private boolean canSetState(@NonNull K key, boolean nextState) {
return mSelectionPredicate.canSetStateForKey(key, nextState);
}
@@ -601,17 +605,21 @@ public class DefaultSelectionTracker<K>
@Override
public void onItemRangeInserted(int startPosition, int itemCount) {
- mSelectionTracker.endRange();
+ if (mSelectionTracker.isOverlapping(startPosition, itemCount))
+ mSelectionTracker.endRange();
}
@Override
public void onItemRangeRemoved(int startPosition, int itemCount) {
- mSelectionTracker.endRange();
+ if (mSelectionTracker.isOverlapping(startPosition, itemCount))
+ mSelectionTracker.endRange();
}
@Override
public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
- mSelectionTracker.endRange();
+ if (mSelectionTracker.isOverlapping(fromPosition, itemCount) ||
+ mSelectionTracker.isOverlapping(toPosition, itemCount))
+ mSelectionTracker.endRange();
}
}
}
diff -rupN /home/marcel/support/recyclerview/recyclerview-selection/src/main/java/androidx/recyclerview/selection/Range.java app/src/main/java/androidx/recyclerview/selection/Range.java
--- /home/marcel/support/recyclerview/recyclerview-selection/src/main/java/androidx/recyclerview/selection/Range.java 2020-03-23 17:03:46.045122318 +0100
+++ app/src/main/java/androidx/recyclerview/selection/Range.java 2020-04-24 21:08:55.543011257 +0200
@@ -169,6 +169,11 @@ final class Range {
mCallbacks.updateForRange(begin, end, selected, type);
}
+ boolean isOverlapping(int position, int count) {
+ return (position >= mBegin && position <= mEnd) ||
+ (position + count >= mBegin && position + count <= mEnd);
+ }
+
@Override
public String toString() {
return "Range{begin=" + mBegin + ", end=" + mEnd + "}";
diff -rupN /home/marcel/support/recyclerview/recyclerview-selection/src/main/java/androidx/recyclerview/selection/SelectionTracker.java app/src/main/java/androidx/recyclerview/selection/SelectionTracker.java
--- /home/marcel/support/recyclerview/recyclerview-selection/src/main/java/androidx/recyclerview/selection/SelectionTracker.java 2020-03-23 17:03:46.046122318 +0100
+++ app/src/main/java/androidx/recyclerview/selection/SelectionTracker.java 2020-04-24 21:08:55.544011257 +0200
@@ -503,7 +503,7 @@ public abstract class SelectionTracker<K
private OnContextClickListener mOnContextClickListener; private OnContextClickListener mOnContextClickListener;
private BandPredicate mBandPredicate; private BandPredicate mBandPredicate;
@ -11,7 +64,7 @@ index 50cc4ceb7..910935a0a 100644
// TODO(b/144500333): Remove support for overriding gesture and pointer tooltypes. // TODO(b/144500333): Remove support for overriding gesture and pointer tooltypes.
private int[] mGestureToolTypes = new int[]{ private int[] mGestureToolTypes = new int[]{
@@ -815,7 +815,11 @@ public abstract class SelectionTracker<K> { @@ -815,7 +815,11 @@ public abstract class SelectionTracker<K
@Override @Override
public void run() { public void run() {
if (mSelectionPredicate.canSelectMultiple()) { if (mSelectionPredicate.canSelectMultiple()) {
@ -24,19 +77,3 @@ index 50cc4ceb7..910935a0a 100644
} }
} }
}, },
diff --git a/app/src/main/java/androidx/recyclerview/selection/TouchInputHandler.java b/app/src/main/java/androidx/recyclerview/selection/TouchInputHandler.java
index be4c3fa0b..c434ced07 100644
--- a/app/src/main/java/androidx/recyclerview/selection/TouchInputHandler.java
+++ b/app/src/main/java/androidx/recyclerview/selection/TouchInputHandler.java
@@ -112,6 +112,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 (DEBUG) {
checkArgument(MotionEvents.isFingerEvent(e));

View file

@ -1,56 +0,0 @@
diff --git a/app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java b/app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java
index 61985cf8d..709308482 100644
--- a/app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java
+++ b/app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java
@@ -379,6 +379,10 @@ public class DefaultSelectionTracker<K> extends SelectionTracker<K> implements R
return mRange != null;
}
+ boolean isOverlapping(int position, int count) {
+ return (mRange != null && mRange.isOverlapping(position, count));
+ }
+
private boolean canSetState(@NonNull K key, boolean nextState) {
return mSelectionPredicate.canSetStateForKey(key, nextState);
}
@@ -601,17 +605,21 @@ public class DefaultSelectionTracker<K> extends SelectionTracker<K> implements R
@Override
public void onItemRangeInserted(int startPosition, int itemCount) {
- mSelectionTracker.endRange();
+ if (mSelectionTracker.isOverlapping(startPosition, itemCount))
+ mSelectionTracker.endRange();
}
@Override
public void onItemRangeRemoved(int startPosition, int itemCount) {
- mSelectionTracker.endRange();
+ if (mSelectionTracker.isOverlapping(startPosition, itemCount))
+ mSelectionTracker.endRange();
}
@Override
public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
- mSelectionTracker.endRange();
+ if (mSelectionTracker.isOverlapping(fromPosition, itemCount) ||
+ mSelectionTracker.isOverlapping(toPosition, itemCount))
+ mSelectionTracker.endRange();
}
}
}
diff --git a/app/src/main/java/androidx/recyclerview/selection/Range.java b/app/src/main/java/androidx/recyclerview/selection/Range.java
index 433e0d2cb..85ddeff94 100644
--- a/app/src/main/java/androidx/recyclerview/selection/Range.java
+++ b/app/src/main/java/androidx/recyclerview/selection/Range.java
@@ -169,6 +169,11 @@ final class Range {
mCallbacks.updateForRange(begin, end, selected, type);
}
+ boolean isOverlapping(int position, int count) {
+ return (position >= mBegin && position <= mEnd) ||
+ (position + count >= mBegin && position + count <= mEnd);
+ }
+
@Override
public String toString() {
return "Range{begin=" + mBegin + ", end=" + mEnd + "}";