From f2caf6ed5bfdd79736d5aabb79e4bab7199861fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E6=B0=B8=E5=BF=97?= Date: Thu, 11 Oct 2018 17:15:53 +0800 Subject: [PATCH] add support second double tap --- .../java/com/github/chrisbanes/photoview/PhotoView.java | 4 ++++ .../github/chrisbanes/photoview/PhotoViewAttacher.java | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoView.java b/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoView.java index 8a8ba0a7..7479e741 100644 --- a/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoView.java +++ b/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoView.java @@ -150,6 +150,10 @@ public void setZoomable(boolean zoomable) { attacher.setZoomable(zoomable); } + public void setSupportSecondDoubleTap(boolean enable) { + attacher.setSupportSecondDoubleTap(enable); + } + public RectF getDisplayRect() { return attacher.getDisplayRect(); } diff --git a/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java b/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java index 18f1744c..980045da 100644 --- a/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java +++ b/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java @@ -88,6 +88,7 @@ public class PhotoViewAttacher implements View.OnTouchListener, private float mBaseRotation; private boolean mZoomEnabled = true; + private boolean mSecondDoubleTapEnabled = true; private ScaleType mScaleType = ScaleType.FIT_CENTER; private OnGestureListener onGestureListener = new OnGestureListener() { @@ -222,7 +223,7 @@ public boolean onDoubleTap(MotionEvent ev) { float y = ev.getY(); if (scale < getMediumScale()) { setScale(getMediumScale(), x, y, true); - } else if (scale >= getMediumScale() && scale < getMaximumScale()) { + } else if (mSecondDoubleTapEnabled && scale >= getMediumScale() && scale < getMaximumScale()) { setScale(getMaximumScale(), x, y, true); } else { setScale(getMinimumScale(), x, y, true); @@ -482,6 +483,11 @@ public void setZoomable(boolean zoomable) { update(); } + public void setSupportSecondDoubleTap(boolean enable) { + mSecondDoubleTapEnabled = enable; + update(); + } + public void update() { if (mZoomEnabled) { // Update the base matrix using the current drawable