|
|
@@ -1,12 +1,14 @@
|
|
|
package com.yingyang.healthconsultation.adapter
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
+import android.content.Context
|
|
|
import android.text.TextUtils
|
|
|
+import androidx.appcompat.widget.AppCompatImageView
|
|
|
import com.yingyang.healthconsultation.R
|
|
|
import com.yingyang.healthconsultation.databinding.ItemEvaluateBinding
|
|
|
import com.yingyang.healthconsultation.entity.EvaluateRecordsBean
|
|
|
import com.yingyangfly.baselib.adapter.BaseDataBindingAdapter
|
|
|
-import com.yingyangfly.baselib.ext.show
|
|
|
+import com.yingyangfly.baselib.utils.GlideImgUtil
|
|
|
|
|
|
/**
|
|
|
* 评价列表
|
|
|
@@ -14,6 +16,11 @@ import com.yingyangfly.baselib.ext.show
|
|
|
class EvaluateAdapter(override val layoutId: Int = R.layout.item_evaluate) :
|
|
|
BaseDataBindingAdapter<EvaluateRecordsBean, ItemEvaluateBinding>() {
|
|
|
|
|
|
+ private var content: Context? = null
|
|
|
+ fun setContent(content: Context) {
|
|
|
+ this.content = content
|
|
|
+ }
|
|
|
+
|
|
|
@SuppressLint("SetTextI18n")
|
|
|
override fun onBindViewHolder(
|
|
|
binding: ItemEvaluateBinding,
|
|
|
@@ -23,36 +30,39 @@ class EvaluateAdapter(override val layoutId: Int = R.layout.item_evaluate) :
|
|
|
binding.data = item
|
|
|
val index = position + 1
|
|
|
binding.tvTitle.text = "匿名用户$index"
|
|
|
- if (TextUtils.isEmpty(item.value).not()) {
|
|
|
+ if (content != null && TextUtils.isEmpty(item.value).not()) {
|
|
|
val score = item.value.toInt()
|
|
|
if (score > 4) {
|
|
|
- binding.checkboxFive.setBackgroundResource(R.mipmap.icon_star_selected)
|
|
|
+ setImageBackGround(content!!, R.mipmap.icon_star_selected, binding.checkboxFive)
|
|
|
} else {
|
|
|
- binding.checkboxFive.setBackgroundResource(R.mipmap.icon_star_unselected)
|
|
|
+ setImageBackGround(content!!, R.mipmap.icon_star_unselected, binding.checkboxFive)
|
|
|
}
|
|
|
if (score > 3) {
|
|
|
- binding.checkboxFour.setBackgroundResource(R.mipmap.icon_star_selected)
|
|
|
+ setImageBackGround(content!!, R.mipmap.icon_star_selected, binding.checkboxFour)
|
|
|
} else {
|
|
|
- binding.checkboxFour.setBackgroundResource(R.mipmap.icon_star_unselected)
|
|
|
+ setImageBackGround(content!!, R.mipmap.icon_star_unselected, binding.checkboxFour)
|
|
|
}
|
|
|
if (score > 2) {
|
|
|
- binding.checkboxThree.setBackgroundResource(R.mipmap.icon_star_selected)
|
|
|
+ setImageBackGround(content!!, R.mipmap.icon_star_selected, binding.checkboxThree)
|
|
|
} else {
|
|
|
- binding.checkboxThree.setBackgroundResource(R.mipmap.icon_star_unselected)
|
|
|
+ setImageBackGround(content!!, R.mipmap.icon_star_unselected, binding.checkboxThree)
|
|
|
}
|
|
|
if (score > 1) {
|
|
|
- binding.checkboxTwo.setBackgroundResource(R.mipmap.icon_star_selected)
|
|
|
+ setImageBackGround(content!!, R.mipmap.icon_star_selected, binding.checkboxTwo)
|
|
|
} else {
|
|
|
- binding.checkboxTwo.setBackgroundResource(R.mipmap.icon_star_unselected)
|
|
|
+ setImageBackGround(content!!, R.mipmap.icon_star_unselected, binding.checkboxTwo)
|
|
|
}
|
|
|
if (score > 0) {
|
|
|
- binding.checkboxOne.setBackgroundResource(R.mipmap.icon_star_selected)
|
|
|
+ setImageBackGround(content!!, R.mipmap.icon_star_selected, binding.checkboxOne)
|
|
|
} else {
|
|
|
- binding.checkboxOne.setBackgroundResource(R.mipmap.icon_star_unselected)
|
|
|
+ setImageBackGround(content!!, R.mipmap.icon_star_unselected, binding.checkboxOne)
|
|
|
}
|
|
|
}
|
|
|
binding.tvTime.text = item.createTime
|
|
|
+ }
|
|
|
|
|
|
+ private fun setImageBackGround(content: Context, id: Int, imageview: AppCompatImageView) {
|
|
|
+ GlideImgUtil.loadImage(content, id, imageview)
|
|
|
}
|
|
|
|
|
|
}
|