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

Document Android API for instant click handlers #3022

Open
louwers opened this issue Nov 16, 2024 · 2 comments
Open

Document Android API for instant click handlers #3022

louwers opened this issue Nov 16, 2024 · 2 comments
Labels
android documentation Improvements or additions to documentation

Comments

@louwers
Copy link
Collaborator

louwers commented Nov 16, 2024

Had a discussion with @sargunv on Slack.

It's pretty hard to register a click handler you want to register immediately (without disambiguating double clicks).

Should this be we add some new API for this?

Screen.Recording.2024-11-16.at.02.21.12.mov

Here I copy pasted the implementation of onSingleTap to onSingleTapConfirmed to and commented out the body of onSingleTap.

@louwers louwers added enhancement New feature or request android labels Nov 16, 2024
@sargunv
Copy link
Collaborator

sargunv commented Nov 16, 2024

Minimal Kotlin example of how to do this today without a new API

// map is a MapLibreMap
val gestureManager = map.gesturesManager
gestureManager.detectors.add(SingleTapUpDetector(context, gestureManager))

where SingleTapUpDetector is:

class SingleTapUpDetector(context: Context, gestureManager: AndroidGesturesManager) :
  BaseGesture<StandardOnGestureListener>(context, gestureManager) {
  private val detector = GestureDetector(context, Listener())

  override fun analyzeEvent(event: MotionEvent): Boolean {
    return detector.onTouchEvent(event)
  }

  private class Listener : SimpleStandardOnGestureListener() {
    override fun onSingleTapUp(event: MotionEvent): Boolean {
      println(event)
      return true
    }
  }
}

@louwers louwers added documentation Improvements or additions to documentation and removed enhancement New feature or request labels Nov 17, 2024
@louwers
Copy link
Collaborator Author

louwers commented Nov 17, 2024

Thanks for sharing. I'll make sure this is added to the documentation.

@louwers louwers added bug Something isn't working and removed bug Something isn't working labels Nov 26, 2024
@louwers louwers changed the title Android API for instant click handlers? Document Android API for instant click handlers Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants