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

Support all ClickableSpans, not just URLSpan. #1

Closed
JakeWharton opened this issue Oct 15, 2016 · 5 comments
Closed

Support all ClickableSpans, not just URLSpan. #1

JakeWharton opened this issue Oct 15, 2016 · 5 comments
Assignees

Comments

@JakeWharton
Copy link

As far as I can tell there's no reason to only support URLSpan when ClickableSpans are commonly used for non-URL linking inside text.

@saket
Copy link
Owner

saket commented Oct 15, 2016

Whoa, it's JakeWharton! Alright, calm down. Stop smiling. Act normal.

The reason I chose not to use ClickableSpan was because it does not provide any method to get the span's URL. In comparison, URLSpan has getURL() which makes the job really easy.

@madhu314 has proposed a solution in #2 that basically falls back to scraping the span's text if URLSpan wasn't found as the link. What do you think? :)

@JakeWharton
Copy link
Author

Actually I'm not a big fan of your callback which passes in the URL. Both URLSpan and ClickableSpan have an onClick(View) method that can be invoked. This is the standard way to specify custom clicked behavior of a either of these spans so really all I care about is that it gets invoked.

@saket
Copy link
Owner

saket commented Oct 16, 2016

Interesting. I extracted this library from another personal project where I wanted to listen to URL clicks in TextViews across the app and this looked like the easiest way.

The only other option I could come up with was replacing all spans inserted by Linkify with custom spans (with overriden onClick()), but that did not feel like an optimized solution.

Would you have solved this problem in any other way?

@JakeWharton
Copy link
Author

I've never used Linkify, but I suppose the approach makes sense. I'm solely using ClickableSpan and not using URLs for anything which requires the different approach I described.

@saket saket added the bug label Oct 17, 2016
@saket saket self-assigned this Oct 17, 2016
@saket saket added enhancement and removed bug labels Oct 17, 2016
@saket
Copy link
Owner

saket commented Oct 17, 2016

Alright, merging #2 then. Thanks for contributing, @JakeWharton.

@saket saket closed this as completed Oct 17, 2016
saket added a commit that referenced this issue Oct 17, 2016
Move from URL span handling to clickable span, addresses issue #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants