From bc6a236ca20d7e375ce7fa45e64f78e72b80f417 Mon Sep 17 00:00:00 2001 From: mudar Date: Mon, 11 Sep 2017 14:04:12 -0400 Subject: [PATCH] TouchMode.ALL optimization intercept touch events for both TouchMode vales. In the case of my app, BifacialView is inside a ViewPager. Everything is ok with TouchMode.DELIMITER, but touch gestures were confusing using TouchMode.ALL (BifacialView sets new position, but parent viewPager starts swiping too!). This fixes my bug :) --- .../com/ebr163/bifacialview/view/BifacialView.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/library/src/main/java/com/ebr163/bifacialview/view/BifacialView.java b/library/src/main/java/com/ebr163/bifacialview/view/BifacialView.java index 0fb4513..0ce5a00 100644 --- a/library/src/main/java/com/ebr163/bifacialview/view/BifacialView.java +++ b/library/src/main/java/com/ebr163/bifacialview/view/BifacialView.java @@ -168,22 +168,18 @@ public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: - if (touchMode == TouchMode.DELIMITER) { - if (x > delimiterPosition + delimiterPadding || x < delimiterPosition - delimiterPadding) { - return false; - } else { - getParent().requestDisallowInterceptTouchEvent(true); - } + if ((touchMode == TouchMode.DELIMITER) && + (x > delimiterPosition + delimiterPadding || x < delimiterPosition - delimiterPadding)) { + return false; } + getParent().requestDisallowInterceptTouchEvent(true); case MotionEvent.ACTION_MOVE: isMove = true; break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: isMove = false; - if (touchMode == TouchMode.DELIMITER) { - getParent().requestDisallowInterceptTouchEvent(false); - } + getParent().requestDisallowInterceptTouchEvent(false); break; } delimiterPosition = (int) (x / 1);