package com.yidianling.im.session.viewholder.adapter

import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.yidianling.im.R
import com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean
import com.yidianling.im.session.viewholder.bean.QuestionItemBean

/**
 * @author huozhiliang
 * @描述:
 * @Copyright Copyright (c) 2018
 * @Company 壹点灵
 * @date 2021/6/21
 */
class AdapterLingxiMultipleChoice : RecyclerView.Adapter<AdapterLingxiMultipleChoice.ViewHolder>() {
    private lateinit var tagList: List<String>
    private var onItemClickListener: OnMultiplelItemClickListener? = null

    class ViewHolder(itemView: View) :
        RecyclerView.ViewHolder(itemView) {
        val tv_which_question: TextView = itemView.findViewById(R.id.tv_which_question)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(
            LayoutInflater.from(parent.context).inflate(
                R.layout.im_lingxi_which_question_item,
                parent,
                false
            )
        )
    }

    override fun getItemCount(): Int {
        return tagList.size ?: 0
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
//        holder.tv_which_question.setText("")
//        holder.tv_which_question.setOnClickListener {
//            onItemClickListener?.onMultipleItemClick(
//                LingxiWhichQuestionBean(
//                    isSelected = true,
//                    xquestionPaperId = "0",
//                    xquestionPaperName = "l",
//                    questionId = "1",
//                    questionTitle = "1",
//                    selectType = "1",
//                    selectVals = listOf<QuestionItemBean>(QuestionItemBean(id = "1",name = "2"))
//                ), position
//            )
//        }
    }

    fun setTagData(data: List<String>) {
        tagList = data
        notifyDataSetChanged()
    }

    interface OnMultiplelItemClickListener {
        fun onMultipleItemClick(string: QuestionItemBean, position: Int)
    }
}