From 626367b3226e3a8ffc59e360906e2945b7163a26 Mon Sep 17 00:00:00 2001 From: Jiangbei Date: Thu, 24 Oct 2024 09:01:23 +1100 Subject: [PATCH] add more detailed explanation --- .../player/gesture/CustomBottomSheetBehavior.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/gesture/CustomBottomSheetBehavior.java b/app/src/main/java/org/schabi/newpipe/player/gesture/CustomBottomSheetBehavior.java index d89de9a29f2..ea37ae6aa17 100644 --- a/app/src/main/java/org/schabi/newpipe/player/gesture/CustomBottomSheetBehavior.java +++ b/app/src/main/java/org/schabi/newpipe/player/gesture/CustomBottomSheetBehavior.java @@ -88,23 +88,24 @@ public boolean onInterceptTouchEvent(@NonNull final CoordinatorLayout parent, } } } - // Implement the distance threshold logic + // Implement the distance threshold logic, when the gesture move distance + // is shorter than the threshold, just do not intercept the touch event. switch (event.getActionMasked()) { - case MotionEvent.ACTION_DOWN: + case MotionEvent.ACTION_DOWN://initialize the tracked total distance startY = event.getY(); totalDrag = 0f; break; - case MotionEvent.ACTION_MOVE: + case MotionEvent.ACTION_MOVE://accumulate the total distance final float currentY = event.getY(); totalDrag += Math.abs(currentY - startY); startY = currentY; if (totalDrag < dragThreshold) { - return false; // Do not intercept touch events yet + return false; // Do not intercept touch events yet if shorter than threshold } else { return super.onInterceptTouchEvent(parent, child, event); } case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_CANCEL: + case MotionEvent.ACTION_CANCEL://reset the drag distance and start point totalDrag = 0f; startY = 0f; break;