1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 18:27:43 +00:00
FairEmail/patches/SelectionTracker.patch

118 lines
6.4 KiB
Diff
Raw Normal View History

2020-05-18 14:28:58 +00:00
--- /home/marcel/support/recyclerview/recyclerview-selection/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java 2020-03-23 17:03:46.043122318 +0100
2020-06-26 14:50:27 +00:00
+++ app/src/main/java/androidx/recyclerview/selection/DefaultSelectionTracker.java 2020-06-26 16:48:04.938298254 +0200
2020-05-18 14:28:58 +00:00
@@ -379,6 +379,10 @@ public class DefaultSelectionTracker<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);
}
2020-06-26 14:50:27 +00:00
@@ -390,7 +394,7 @@ public class DefaultSelectionTracker<K>
@SuppressWarnings({"WeakerAccess", "unchecked"}) /* synthetic access */
void onDataSetChanged() {
- mSelection.clearProvisionalSelection();
+ //mSelection.clearProvisionalSelection();
notifySelectionRefresh();
2020-05-18 14:28:58 +00:00
@@ -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();
}
}
}
--- /home/marcel/support/recyclerview/recyclerview-selection/src/main/java/androidx/recyclerview/selection/Range.java 2020-03-23 17:03:46.045122318 +0100
2020-06-26 14:50:27 +00:00
+++ app/src/main/java/androidx/recyclerview/selection/Range.java 2020-06-26 16:36:39.708283142 +0200
2020-05-18 14:28:58 +00:00
@@ -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 + "}";
--- /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
2019-06-07 06:48:03 +00:00
private OnContextClickListener mOnContextClickListener;
private BandPredicate mBandPredicate;
- private int mBandOverlayId = R.drawable.selection_band_overlay;
+ private int mBandOverlayId = eu.faircode.email.R.drawable.selection_band_overlay;
2019-12-08 18:33:02 +00:00
// TODO(b/144500333): Remove support for overriding gesture and pointer tooltypes.
private int[] mGestureToolTypes = new int[]{
2020-05-18 14:28:58 +00:00
@@ -815,7 +815,11 @@ public abstract class SelectionTracker<K
2019-05-09 13:12:47 +00:00
@Override
public void run() {
2019-06-07 06:48:03 +00:00
if (mSelectionPredicate.canSelectMultiple()) {
- gestureHelper.start();
2019-05-09 13:12:47 +00:00
+ try {
+ gestureHelper.start();
2019-12-08 18:33:02 +00:00
+ } catch (Throwable ex) {
+ eu.faircode.email.Log.e(ex);
2019-05-09 13:12:47 +00:00
+ }
2019-06-07 06:48:03 +00:00
}
2019-05-09 13:12:47 +00:00
}
},
2021-10-04 18:10:47 +00:00
--- a/app/src/main/java/androidx/recyclerview/selection/GestureRouter.java
+++ b/app/src/main/java/androidx/recyclerview/selection/GestureRouter.java
@@ -94,7 +94,28 @@ final class GestureRouter<T extends OnGestureListener & OnDoubleTapListener>
@Override
public void onLongPress(@NonNull MotionEvent e) {
- mDelegates.get(e).onLongPress(e);
+ try {
+ mDelegates.get(e).onLongPress(e);
+ } catch (Throwable ex) {
+ eu.faircode.email.Log.w(ex);
+ /*
+ java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling eu.faircode.email.FixedRecyclerView{239c688b VFED.... ........ 0,0-800,1162 #7f0a04da app:id/rvMessage}, adapter:eu.faircode.email.AdapterMessage@209415c5, layout:eu.faircode.email.FragmentMessages$7@190d7b1a, context:eu.faircode.email.ActivityView@3e8522fb
+ at androidx.recyclerview.widget.RecyclerView.assertNotInLayoutOrScroll(SourceFile:3)
+ at androidx.recyclerview.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeChanged(SourceFile:1)
+ at androidx.recyclerview.widget.RecyclerView$AdapterDataObservable.notifyItemRangeChanged(SourceFile:3)
+ at androidx.recyclerview.widget.RecyclerView$Adapter.notifyItemChanged(SourceFile:2)
+ at androidx.recyclerview.selection.EventBridge$TrackerToAdapterBridge.onItemStateChanged(SourceFile:3)
+ at androidx.recyclerview.selection.DefaultSelectionTracker.notifyItemStateChanged(SourceFile:3)
+ at androidx.recyclerview.selection.DefaultSelectionTracker.select(SourceFile:8)
+ at androidx.recyclerview.selection.MotionInputHandler.selectItem(SourceFile:4)
+ at androidx.recyclerview.selection.TouchInputHandler.onLongPress(SourceFile:10)
+ at androidx.recyclerview.selection.GestureRouter.onLongPress(SourceFile:1)
+ at android.view.GestureDetector.dispatchLongPress(GestureDetector.java:700)
+ at android.view.GestureDetector.access$200(GestureDetector.java:40)
+ at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:273)
+ at android.os.Handler.dispatchMessage(Handler.java:102)
+ */
+ }
}
@Override