|
|
@@ -1,19 +1,40 @@
|
|
|
package com.yingyangfly.evaluation.adapter
|
|
|
|
|
|
+import android.text.TextUtils
|
|
|
import com.yingyangfly.baselib.adapter.BaseDataBindingAdapter
|
|
|
import com.yingyangfly.baselib.db.QuestionOptionBean
|
|
|
+import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
import com.yingyangfly.evaluation.R
|
|
|
import com.yingyangfly.evaluation.databinding.ItemQuestionListBinding
|
|
|
-import com.yingyangfly.evaluation.entity.EvaluationHistoryBean
|
|
|
|
|
|
/**
|
|
|
* 选项adapter
|
|
|
*/
|
|
|
class QuestionListAdapter(override val layoutId: Int = R.layout.item_question_list) :
|
|
|
BaseDataBindingAdapter<QuestionOptionBean, ItemQuestionListBinding>() {
|
|
|
+
|
|
|
+ private var selectedType = ""
|
|
|
+
|
|
|
+ var onClickListener: ((bean: QuestionOptionBean) -> Unit)? = null
|
|
|
+
|
|
|
+ fun setContent(selectedType: String) {
|
|
|
+ this.selectedType = selectedType
|
|
|
+ }
|
|
|
+
|
|
|
override fun onBindViewHolder(
|
|
|
binding: ItemQuestionListBinding, item: QuestionOptionBean, position: Int
|
|
|
) {
|
|
|
binding.data = item
|
|
|
+ if (TextUtils.isEmpty(selectedType).not() && TextUtils.equals(
|
|
|
+ selectedType, item.optionVal
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ binding.tvTitle.setOnSingleClickListener {
|
|
|
+ onClickListener?.invoke(item)
|
|
|
+ }
|
|
|
}
|
|
|
}
|