Skip to content

Commit

Permalink
fix bug cache span
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyễn Chí Hùng committed Aug 31, 2020
1 parent f788f67 commit 59f76be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 8 additions & 4 deletions app/src/main/java/io/github/armcha/RecyclerViewActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ class RecyclerViewActivity : AppCompatActivity() {
val context = holder.itemView.context
val custom = MODE_CUSTOM("\\sAndroid\\b")

autoLinkTextView.setMentionsByOffset(mentions = ArrayList<Pair<Int,Int>>().apply {
add(Pair(0,12))
add(Pair(13,23))
},backgroundColor = ContextCompat.getColor(context,R.color.color1),textColor = Color.WHITE,mentionStyle = Typeface.DEFAULT_BOLD)
if(position%2==0){
autoLinkTextView.setMentionsByOffset(mentions = ArrayList<Pair<Int,Int>>().apply {
add(Pair(0,12))
add(Pair(13,23))
},backgroundColor = ContextCompat.getColor(context,R.color.color1),textColor = Color.WHITE,mentionStyle = Typeface.DEFAULT_BOLD)
}else{
autoLinkTextView.setMentionsByOffset(mentions = ArrayList())
}

autoLinkTextView.addAutoLinkMode(
MODE_HASHTAG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ class AutoLinkTextView(context: Context, attrs: AttributeSet? = null) : TextView
private var mentionPaddingEnd: Float = 20f
private var mentionMarginStart: Float = 20f
private var mentionStyle: Typeface = Typeface.DEFAULT_BOLD
fun setMentionsByOffset(mentions:ArrayList<Pair<Int,Int>>,backgroundColor: Int,textColor: Int,cornerRadius: Float = 10f, paddingStart: Float= 20f,paddingEnd: Float= 20f,marginStart: Float= 20f
, mentionStyle:Typeface
fun setMentionsByOffset(mentions:ArrayList<Pair<Int,Int>> = ArrayList(), backgroundColor: Int = 0, textColor: Int = 0, cornerRadius: Float = 10f, paddingStart: Float= 20f, paddingEnd: Float= 20f, marginStart: Float= 20f
, mentionStyle:Typeface = Typeface.DEFAULT
){
this.spanOffset.clear()
this.spanOffset.addAll(mentions)
this.mentionBackgroundColor = backgroundColor
mentionTextColor = textColor
Expand Down

0 comments on commit 59f76be

Please sign in to comment.