Revert "Prevent long press from leaking into header gesture detector"

This reverts commit 935114fc4c.
master
M66B 5 days ago
parent 935114fc4c
commit 4575cfc8bf

@ -389,8 +389,6 @@ public class FragmentMessages extends FragmentBase
private boolean scrolling = false; private boolean scrolling = false;
private boolean navigating = false; private boolean navigating = false;
private GestureDetector gestureDetector;
private AdapterMessage adapter; private AdapterMessage adapter;
private AdapterMessage.ViewType viewType; private AdapterMessage.ViewType viewType;
@ -1198,12 +1196,15 @@ public class FragmentMessages extends FragmentBase
}; };
rvMessage.addItemDecoration(dateDecorator); rvMessage.addItemDecoration(dateDecorator);
gestureDetector = rvMessage.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
private final GestureDetector gestureDetector =
new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
@Override @Override
public void onLongPress(@NonNull MotionEvent e) { public void onLongPress(@NonNull MotionEvent e) {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
return; return;
if (swiping)
return;
int x = Math.round(e.getX()); int x = Math.round(e.getX());
int y = Math.round(e.getY()); int y = Math.round(e.getY());
@ -1256,7 +1257,6 @@ public class FragmentMessages extends FragmentBase
} }
}); });
rvMessage.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
@Override @Override
public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) { public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
gestureDetector.onTouchEvent(e); gestureDetector.onTouchEvent(e);
@ -3282,7 +3282,6 @@ public class FragmentMessages extends FragmentBase
@Override @Override
public void run() { public void run() {
swiping = false; swiping = false;
gestureDetector.setIsLongpressEnabled(true);
Log.i("Swiping ended"); Log.i("Swiping ended");
} }
}; };
@ -3293,7 +3292,6 @@ public class FragmentMessages extends FragmentBase
getMainHandler().removeCallbacks(disableSwiping); getMainHandler().removeCallbacks(disableSwiping);
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
swiping = true; swiping = true;
gestureDetector.setIsLongpressEnabled(false);
Log.i("Swiping started"); Log.i("Swiping started");
} else } else
getMainHandler().postDelayed(disableSwiping, ViewConfiguration.getLongPressTimeout() + 100); getMainHandler().postDelayed(disableSwiping, ViewConfiguration.getLongPressTimeout() + 100);

Loading…
Cancel
Save