Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
String strings = Utils.decodeString(mChannelObj.getDescription());
tvDescription.setVisibility(VISIBLE);
descriptionDivView.setVisibility(VISIBLE);
SpannableStringBuilder span = new SpannableStringBuilder(strings);
Pattern webPattern = Patterns.WEB_URL;
Matcher matcher = webPattern.matcher(Utils.decodeString(mChannelObj.getDescription()));
while (matcher.find()) {
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
Logger.d(TAG, "text clicked ");
}
};
String links = matcher.group();
Logger.d(TAG, "links " + links);
int startingPoint = Utils.decodeString(mChannelObj.getDescription()).indexOf(links);
int endingPoint = Utils.decodeString(mChannelObj.getDescription()).indexOf(links) + links.length();
Logger.d(TAG, startingPoint + " - " + endingPoint);
span.setSpan(clickableSpan, startingPoint, endingPoint, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
tvDescription.setMovementMethod(LinkMovementMethod.getInstance());
tvDescription.setText(span, TextView.BufferType.SPANNABLE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.