2019-08-03 14:49:46 +00:00
|
|
|
diff --git a/app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java b/app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java
|
2020-01-26 11:16:28 +00:00
|
|
|
index 61985cf8d..709308482 100644
|
2019-08-03 14:49:46 +00:00
|
|
|
--- a/app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java
|
|
|
|
+++ b/app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java
|
2020-01-26 11:16:28 +00:00
|
|
|
@@ -379,6 +379,10 @@ public class DefaultSelectionTracker<K> extends SelectionTracker<K> implements R
|
2019-08-03 14:49:46 +00:00
|
|
|
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);
|
|
|
|
}
|
2020-01-26 11:16:28 +00:00
|
|
|
@@ -601,17 +605,21 @@ public class DefaultSelectionTracker<K> extends SelectionTracker<K> implements R
|
2019-08-03 14:49:46 +00:00
|
|
|
|
|
|
|
@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
|
2020-01-26 11:16:28 +00:00
|
|
|
index 433e0d2cb..85ddeff94 100644
|
2019-08-03 14:49:46 +00:00
|
|
|
--- a/app/src/main/java/androidx/recyclerview/selection/Range.java
|
|
|
|
+++ b/app/src/main/java/androidx/recyclerview/selection/Range.java
|
2020-01-26 11:16:28 +00:00
|
|
|
@@ -169,6 +169,11 @@ final class Range {
|
2019-08-03 14:49:46 +00:00
|
|
|
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 + "}";
|