hanggrian / socialview

Android TextView and EditText with hashtag, mention, and hyperlink support
https://hendraanggrian.github.io/socialview/
Apache License 2.0
322 stars 81 forks source link

Help on retrieving position of mentions and hashtags #86

Closed gruppotognetto closed 3 years ago

gruppotognetto commented 3 years ago

Hi,

before saying anything, i'd like to thank you for this library, because it's saving my life!

I'm in need of some support because i have some specifics that your library doesn't fulfill:

  1. I need to know something more about the mention. I've implemented the Mentionable interface and when i call the mentions method, what the SocialAutoCompleteTextView returns me is a list of String, but i need the source Object and not the String representation... If you can point me in the right direction, i can try to extend SocialAutoCompleteTextView class to have this information...
  2. Is it possible to get the exact position (start and length) of the spans of every mention? If not, is there a way to extract this information? (maybe from the getSpans(...) method on the editable?)
  3. I think this is a bug: when i try to get all the hashtags (via the getHashtags method), it goes in IndexOutOfBoundsException, precisely with this stacktrace:
java.lang.IndexOutOfBoundsException: No group 1
        at java.util.regex.Matcher.group(Matcher.java:458)
        at com.hendraanggrian.appcompat.widget.SocialViewHelper.listOf(SocialViewHelper.java:456)
        at com.hendraanggrian.appcompat.widget.SocialViewHelper.getHashtags(SocialViewHelper.java:353)
        at com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView.getHashtags(SocialAutoCompleteTextView.java:347)

I don't know if you need some other information about my env, but if needed, i'll try to explain better

PS: Sorry for the bad english... It's not my first language.