Created
July 25, 2019 18:01
-
-
Save bansalayush/98fbac020b06dc6b99caa082d6d96d63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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