Skip to content

Commit 34414ca

Browse files
Fix bug x2 CameraView.java
1 parent 81fd8a1 commit 34414ca

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,12 @@ public boolean onTouchEvent(MotionEvent event) {
658658
// Pass to our own GestureLayouts
659659
CameraOptions options = mCameraEngine.getCameraOptions(); // Non null
660660
if (options == null) throw new IllegalStateException("Options should not be null here.");
661+
662+
boolean ongoingPinchEvent = false;
661663
if (mPinchGestureFinder.onTouchEvent(event)) {
662664
LOG.i("onTouchEvent", "pinch!");
663665
onGesture(mPinchGestureFinder, options);
666+
ongoingPinchEvent = true;
664667
} else if (mScrollGestureFinder.onTouchEvent(event)) {
665668
LOG.i("onTouchEvent", "scroll!");
666669
onGesture(mScrollGestureFinder, options);
@@ -669,8 +672,8 @@ public boolean onTouchEvent(MotionEvent event) {
669672
onGesture(mTapGestureFinder, options);
670673
}
671674

672-
// Only detect swipes for single-finger gestures
673-
if(event.getPointerCount() == 1) {
675+
// Only detect swipes for single-finger gestures that haven't been handled by pinch gesture finder
676+
if(!ongoingPinchEvent && event.getPointerCount() == 1) {
674677
if(event.getAction() == MotionEvent.ACTION_DOWN) x1 = event.getX();
675678
if(event.getAction() == MotionEvent.ACTION_UP) {
676679
x2 = event.getX();

0 commit comments

Comments
 (0)