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

Conflict with other library #28

Closed Rakhimjon closed 3 years ago

Rakhimjon commented 6 years ago

I can't use with https://github.com/bravoborja/ReadMoreTextView library. Your library was removing click function from more text screenshot_2017-11-01-11-47-37

Rakhimjon commented 6 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?

hanggrian commented 6 years ago

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.

hanggrian commented 3 years ago

Closed due to inactivity.