From 727bd490d3a2b4ec955716cf57fe0fd78e2ad54e Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 26 Dec 2016 19:09:07 +0100 Subject: [PATCH] allow only pinch zooming, not double tap --- .../gallery/views/MyScalableRecyclerView.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/views/MyScalableRecyclerView.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/views/MyScalableRecyclerView.kt index c69e2930d..0fc41e885 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/views/MyScalableRecyclerView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/views/MyScalableRecyclerView.kt @@ -12,6 +12,7 @@ class MyScalableRecyclerView : RecyclerView { companion object { var mListener: ZoomListener? = null var mCurrScaleFactor = 1.0f + var mLastUp = 0L // allow only pinch zoom, not double tap } constructor(context: Context) : super(context) { @@ -28,6 +29,7 @@ class MyScalableRecyclerView : RecyclerView { super.dispatchTouchEvent(ev) if (ev.action == MotionEvent.ACTION_UP) { mCurrScaleFactor = 1.0f + mLastUp = System.currentTimeMillis() } return mScaleDetector.onTouchEvent(ev) @@ -38,6 +40,9 @@ class MyScalableRecyclerView : RecyclerView { val ZOOM_OUT_THRESHOLD = 0.3f override fun onScale(detector: ScaleGestureDetector): Boolean { + if (System.currentTimeMillis() - mLastUp < 1000) + return false + val diff = mCurrScaleFactor - detector.scaleFactor if (diff < ZOOM_IN_THRESHOLD && mCurrScaleFactor == 1.0f) { mListener?.zoomIn()