hanggrian / socialview

Android TextView and EditText with hashtag, mention, and hyperlink support
http://hanggrian.com/socialview/
Apache License 2.0
324 stars 81 forks source link

Hyperlink click listener #18

Closed CripyIce closed 7 years ago

CripyIce commented 7 years ago

Hi there @HendraAnggrian, Is there any way i can listen to hyperlink clicks and get the URL of it? Thanks.

hanggrian commented 7 years ago

@CripyIce sorry for the delayed response, I just read this issue. I am seriously considering your suggestion since hyperlink implementation can be different from app to app.

I'm also considering displaying quick webpage as suggestion to hyperlink.

CripyIce commented 7 years ago

Hi there, no problem at all! So, what do you suggest I could do in the meanwhile?

hanggrian commented 7 years ago

For now hyperlinks can be retrieved this way:

@NonNull
private static <V extends TextView & SocialView> Collection<String> getHyperlinks(@NonNull V v) {
    Collection<String> list = new ArrayList<>();
    if (!v.isHyperlinkEnabled()) {
        return list;
        }
    Matcher matcher = Patterns.WEB_URL.matcher(v.getText());
    while (matcher.find()) {
        list.add(matcher.group(0));
    }
    return list;
}

I'll update this thread for more updates :)

CripyIce commented 7 years ago

Great!! I'll check it later.. and will wait for updates on this thread. Thanks!!!

CripyIce commented 7 years ago

Hi @HendraAnggrian, been a busy week, but now that i'm on it i see that i can get a collection of the hyperlinks there are in the textview for example. But what i wanted is an example of listening to hyperlink clicks. For example, i have a textview with an URL written inside and i want when user click that URL it will open chrome custom tabs. Any idea?

hanggrian commented 7 years ago

@CripyIce my bad I might have misunderstood the request last week. I understand now that hyperlink clicks needs to be customized as well. New version is almost ready with this feature (along with others), I just need to complete few tests.

CripyIce commented 7 years ago

@HendraAnggrian looking forward for this update! Thanks man.

hanggrian commented 7 years ago

Version 0.16.2 is out with custom hyperlink click listener, let me know how that works for you.

CripyIce commented 7 years ago

@HendraAnggrian Great!! it works well and finally i can listen to hyperlink clicks. Thanks man!