diff --git a/app/src/main/java/se/ajpanton/notificationlog/ZoomImageView.kt b/app/src/main/java/se/ajpanton/notificationlog/ZoomImageView.kt index 55a75b2..c82f2e2 100644 --- a/app/src/main/java/se/ajpanton/notificationlog/ZoomImageView.kt +++ b/app/src/main/java/se/ajpanton/notificationlog/ZoomImageView.kt @@ -27,6 +27,7 @@ class ZoomImageView @JvmOverloads constructor( private var lastFocusX = 0f private var lastFocusY = 0f private var pointerCount = 0 + private var quickScaleGesture = false private val scaleDetector = ScaleGestureDetector(context, object : ScaleGestureDetector.SimpleOnScaleGestureListener() { override fun onScaleBegin(detector: ScaleGestureDetector): Boolean { lastFocusX = detector.focusX @@ -54,6 +55,18 @@ class ZoomImageView @JvmOverloads constructor( return true } + override fun onDoubleTap(event: MotionEvent): Boolean { + quickScaleGesture = true + return true + } + + override fun onDoubleTapEvent(event: MotionEvent): Boolean { + if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) { + quickScaleGesture = false + } + return true + } + }) init { @@ -81,7 +94,7 @@ class ZoomImageView @JvmOverloads constructor( lastY = event.y dragging = false } - MotionEvent.ACTION_MOVE -> if (event.pointerCount == 1 && !scaleDetector.isInProgress) { + MotionEvent.ACTION_MOVE -> if (event.pointerCount == 1 && !scaleDetector.isInProgress && !quickScaleGesture) { val dx = event.x - lastX val dy = event.y - lastY if (dx != 0f || dy != 0f) {