saket / Better-Link-Movement-Method

Attempts to improve how clickable links are detected, highlighted and handled in TextView
Apache License 2.0
780 stars 78 forks source link

Feature Request: Add doubleClickListener #47

Open AniruddhaChattopadhyay opened 2 years ago

AniruddhaChattopadhyay commented 2 years ago

Feature Request

Hey @saket, ​Amazing library. Has really helped out a lot. I have a new feature request to make. Currently, only single click and long click listeners are available in Better-Link-Movement-Method. It would be great if a double-tap listener is also made available in addition to these listeners.

Use Cases

There are a lot of use cases, one of the most prominent being double-tap to like a post (like that on Instagram). So anyone who is building a feed that contains posts with text, images, and videos might want to include the double-tap to like feature. A lot of the posts do have links in them, now for the links, one can use Better-Link-Movement-Method to handle the click events, but then the double-tap to like feature goes for a toss. To have an onTouchListener on the entire textView and use gestureDetector to detect double click is an option but then on clicking the link the onTouch of the textView is triggered thus link handling is undone.

Solution

The Solution I have used in my case is to extend BetterLinkMovement to my own class and then create an OnDoubleClickListener there to handle the double clicks. If we can include the listener in the library itself, that would help out of a lot of people. I can work on this feature if you want