package waific.Teflonic.therapistic

import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.easy.clean.R
import tooic.fatalityic.corroborateic.Protegeic
import com.easy.clean.databinding.MilitaryicBinding
import com.easy.clean.databinding.TranspireicBinding
import tooic.fatalityic.redic.speckledic.hankeringic.Devastatingic.inflate
import com.chad.library.adapter4.BaseQuickAdapter

class Insincereic : BaseQuickAdapter<Protegeic, Insincereic.Koko8888>() {

    inner class Koko8888(view: View) : ViewHolder(view)

    var itemClick: ((bean: Protegeic) -> Unit)? = null

    override fun getItemViewType(position: Int, list: List<Protegeic>): Int {
        val bean = list[position]
        return bean.span
    }

    override fun onBindViewHolder(holder: Koko8888, position: Int, item: Protegeic?) {
        item ?: return
        val context = holder.itemView.context
        when (item.span) {
            1 -> {
                val binding = TranspireicBinding.bind(holder.itemView)
                binding.slutic.setImageResource(item.icon)
                binding.consequentic.text = context.getString(item.titleRes)
                binding.root.setOnClickListener {
                    itemClick?.invoke(item)
                }
            }

            3 -> {
                val binding = MilitaryicBinding.bind(holder.itemView)
                binding.slutic.setImageResource(item.icon)
                binding.consequentic.text = context.getString(item.titleRes)
                binding.root.setOnClickListener {
                    itemClick?.invoke(item)
                }
            }
        }
    }

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): Koko8888 {

        val layout = when (viewType) {
            1 -> R.layout.transpireic
            3 -> R.layout.militaryic
            else -> 0
        }
        return Koko8888(layout.inflate(parent))
    }
}