mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-04 11:54:10 +01:00
Fixed selection/update
Where did this patch go?
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 + "}";
|
||||
|
||||
Reference in New Issue
Block a user