Closed Rakhimjon closed 3 years ago
I've commented one line from your code and it works.
override fun colorize() {
val spannable = view.text
check(spannable is Spannable, { "Attached text is not a Spannable, add TextView.BufferType.SPANNABLE when setting text to this TextView." })
spannable as Spannable
// spannable.removeSpans(CharacterStyle::class.java)
if (isHashtagEnabled) {
spannable.putSpansAll(SocialView.HASHTAG_PATTERN, {
mHashtagListener?.newClickableSpan(spannable, mHashtagColor) ?: ForegroundColorSpan(mHashtagColor.defaultColor)
})
}
if (isMentionEnabled) {
spannable.putSpansAll(SocialView.MENTION_PATTERN, {
mMentionListener?.newClickableSpan(spannable, mMentionColor) ?: ForegroundColorSpan(mMentionColor.defaultColor)
})
}
if (isHyperlinkEnabled) {
spannable.putSpansAll(SocialView.HYPERLINK_PATTERN, {
mHyperlinkListener?.newClickableSpan(spannable, mHyperlinkColor, true) ?: object : ForegroundColorSpan(mMentionColor.defaultColor) {
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
ds.isUnderlineText = true
}
}
})
}
}
Maybe it's wrong. Why you removing clickable spans?
Pardon my slow learning, I fail to understand what you're trying to achieve here. That removeSpans
is necessary to clear up old spans before adding new ones.
Closed due to inactivity.
I can't use with https://github.com/bravoborja/ReadMoreTextView library. Your library was removing click function from more text