Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support second double tap #649

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down