zoomage icon indicating copy to clipboard operation
zoomage copied to clipboard

Add Double Tab Listner

Open santhoshdasari786 opened this issue 7 years ago • 6 comments

I want to customize double tab listener to move to next image , But not able to do as listener is observed.

santhoshdasari786 avatar Jun 06 '18 17:06 santhoshdasari786

Do you mean double tap?

jsibbold avatar Jun 11 '18 16:06 jsibbold

Ya I want to Implement click Listener to implement Double Tab. I want custom listeners in Library to listen to Double Tab Events and Execute my own logic.

santhoshdasari786 avatar Jun 14 '18 05:06 santhoshdasari786

@santhoshdasari786 Current code base doesn't provide any mean to listen to Zoom changes neither to listen to gesture detector. @jsibbold please advise

aouledissa avatar Feb 14 '19 15:02 aouledissa

Okay, I can look into adding some sort of listener to zoom changes and tap events. Currently my time to work on this library is scarce because of work, but I will do my best to put in some work on this.

jsibbold avatar Feb 20 '19 16:02 jsibbold

Okay, I can look into adding some sort of listener to zoom changes and tap events. Currently my time to work on this library is scarce because of work, but I will do my best to put in some work on this.

I could do that via a pull request.

aouledissa avatar Feb 20 '19 16:02 aouledissa

@santhoshdasari786 you can use something like this (Kotlin): Create this class:

class GestureListener(): GestureDetector.SimpleOnGestureListener() {
    override fun onDoubleTap(e: MotionEvent?): Boolean {
        super.onDoubleTap(e)
        // Do whatever you want
        return true;
    }
}

And when you want to set the listener:

val detector = GestureDetectorCompat(context, GestureListener()) // Change context with the context you use, it can be 'this' if on an activity
// zoomage_view is your Zoomage image view, you can use it directly from the activity class, or with findViewById
zoomage_view.setOnTouchListener { v, event ->
    v.performClick() // On touch lambda should run performClick on the view.
    detector.onTouchEvent(event)
}

And with just this you should be able to go. Also, for a shorter version, without creating extra classes, you can use:

zoomage_view.setOnTouchListener { v, event ->
    GestureDetectorCompat(this@MainActivity,
        object : GestureDetector.SimpleOnGestureListener() {
            override fun onDoubleTap(e: MotionEvent?): Boolean {
                super.onDoubleTap(e)
                // Do whatever you want
                return true
            }
        }
    ).onTouchEvent(event)
}

Hope this can help you ;)

ArnyminerZ avatar Apr 08 '20 22:04 ArnyminerZ