Skip to content

Commit 1e91d1a

Browse files
author
Bony
committed
update function
1 parent 5a68921 commit 1e91d1a

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

library_tagflow/src/main/java/com/framework/tagflow/adapter/BaseTagAdapter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ abstract class BaseTagAdapter<T> : BaseAdapter() {
5959
return
6060
}
6161
if(dataList[position] is BaseTagBean){
62-
(dataList[position] as BaseTagBean).setSelected(true)
62+
(dataList[position] as BaseTagBean).setIsSelected(true)
6363
}
6464
}
6565

@@ -71,7 +71,7 @@ abstract class BaseTagAdapter<T> : BaseAdapter() {
7171
return
7272
}
7373
if(dataList[position] is BaseTagBean){
74-
(dataList[position] as BaseTagBean).setSelected(false)
74+
(dataList[position] as BaseTagBean).setIsSelected(false)
7575
}
7676

7777
}

library_tagflow/src/main/java/com/framework/tagflow/bean/BaseTagBean.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package com.framework.tagflow.bean
99
open class BaseTagBean {
1010
private var id = 0
1111
private var name: String? = null
12-
private var selected = false//是否选中
12+
private var isSelected = false//是否选中
1313
private var tag: Any? = null //标签额外信息
1414

1515
fun getId(): Int {
@@ -37,10 +37,10 @@ open class BaseTagBean {
3737
}
3838

3939
fun isSelected(): Boolean {
40-
return selected
40+
return isSelected
4141
}
4242

43-
fun setSelected(selected: Boolean) {
44-
this.selected = selected
43+
fun setIsSelected(selected: Boolean) {
44+
this.isSelected = selected
4545
}
4646
}

library_tagflow/src/main/java/com/framework/tagflow/tags/DefaultTagView.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import android.util.AttributeSet
88
import android.view.Gravity
99
import androidx.annotation.ColorInt
1010
import androidx.appcompat.widget.AppCompatTextView
11+
import androidx.core.content.ContextCompat
1112
import com.framework.tagflow.utils.DensityUtils
1213
import com.framework.tagflow.R
1314

@@ -52,7 +53,7 @@ open class DefaultTagView @JvmOverloads constructor(
5253
//返回一个Drawable背景样式
5354
protected open fun getBackgroundDrawable(): Drawable? {
5455
//设置字体颜色的选择器
55-
val colorSateList = mContext.resources.getColorStateList(R.color.secondary_text)
56+
val colorSateList =ContextCompat.getColorStateList(context,R.color.secondary_text)
5657
setTextColor(colorSateList)
5758
val normal = GradientDrawable()
5859
normal.shape = GradientDrawable.RECTANGLE

library_tagflow/src/main/java/com/framework/tagflow/tags/MutSelectedTagView.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable
66
import android.graphics.drawable.GradientDrawable
77
import android.graphics.drawable.StateListDrawable
88
import android.util.AttributeSet
9+
import androidx.core.content.ContextCompat
910
import com.framework.tagflow.utils.DensityUtils
1011
import com.framework.tagflow.R
1112

@@ -29,7 +30,7 @@ class MutSelectedTagView : DefaultTagView {
2930

3031
override fun getBackgroundDrawable(): Drawable? {
3132
//设置字体颜色的选择器
32-
val colorSateList = mContext.resources.getColorStateList(R.color.secondary_text)
33+
val colorSateList = ContextCompat.getColorStateList(context,R.color.secondary_text)
3334
setTextColor(colorSateList)
3435
val normal = GradientDrawable()
3536
normal.shape = GradientDrawable.RECTANGLE

0 commit comments

Comments
 (0)