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 Double Tab Listner #55

Open
santhoshdasari786 opened this issue Jun 6, 2018 · 6 comments
Open

Add Double Tab Listner #55

santhoshdasari786 opened this issue Jun 6, 2018 · 6 comments
Labels

Comments

@santhoshdasari786
Copy link

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

@jsibbold jsibbold added the want label Jun 7, 2018
@jsibbold
Copy link
Owner

Do you mean double tap?

@santhoshdasari786
Copy link
Author

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.

@aouledissa
Copy link

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

@jsibbold
Copy link
Owner

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.

@aouledissa
Copy link

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.

@ArnyminerZ
Copy link

@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 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants