diff --git a/zoomage/src/main/java/com/jsibbold/zoomage/ZoomageView.java b/zoomage/src/main/java/com/jsibbold/zoomage/ZoomageView.java index f1e6f76..4f5438a 100644 --- a/zoomage/src/main/java/com/jsibbold/zoomage/ZoomageView.java +++ b/zoomage/src/main/java/com/jsibbold/zoomage/ZoomageView.java @@ -90,6 +90,9 @@ public class ZoomageView extends AppCompatImageView implements OnScaleGestureLis private boolean doubleTapDetected = false; private boolean singleTapDetected = false; + //listener + private onZoomageViewDoubleClickListener doubleClickListener; + public ZoomageView(Context context) { super(context); init(context, null); @@ -387,6 +390,15 @@ public void setImageBitmap(Bitmap bm) { setScaleType(startScaleType); } +/** + * the zoomage double click listener + * + * @param doubleClickListener The double click listener + */ + public void setOnDoubleClickListener(onZoomageViewDoubleClickListener doubleClickListener){ + this.doubleClickListener = doubleClickListener; + } + /** * {@inheritDoc} */ @@ -477,7 +489,16 @@ public boolean onTouchEvent(MotionEvent event) { zoomMatrix.postScale(doubleTapToZoomScaleFactor, doubleTapToZoomScaleFactor, scaleDetector.getFocusX(), scaleDetector.getFocusY()); animateScaleAndTranslationToMatrix(zoomMatrix, RESET_DURATION); } + //notify onclick listeners + doubleClickListener.onDoubleClick(doubleTapToZoom); + //rest double Tap detected + doubleTapDetected = false; return true; + }else if (!doubleTapToZoom && doubleTapDetected) { + //notify onclick listeners + doubleClickListener.onDoubleClick(doubleTapToZoom); + //rest double Tap detected + doubleTapDetected = false; } else if (!singleTapDetected) { /* if the event is a down touch, or if the number of touch points changed, * we should reset our start point, as event origins have likely shifted to a @@ -915,4 +936,13 @@ public void onAnimationCancel(Animator animation) { public void onAnimationRepeat(Animator animation) { } } + + public interface onZoomageViewDoubleClickListener{ + /** + * Called on double click. + * + * @param isDoubleTapToZoom Indicates if double tap was made as zoom action + */ + public void onDoubleClick(boolean isDoubleTapToZoom); + } }