package rowedto.jockeyedto.sheetedto.meadowedto.naturaledto.idealedto

import android.annotation.SuppressLint
import android.view.View
import android.view.ViewGroup
import androidx.annotation.Dimension
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.base.datarecovery.R
import com.base.datarecovery.databinding.ChequeedtoBinding
import rowedto.jockeyedto.sheetedto.balsamedto.formaledto.orientationedto.Ambitionedto.inflate
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Treatedto

class Noiseedto(
    val click: (bean: Treatedto) -> Unit
) : RecyclerView.Adapter<Noiseedto.YYDS>() {

    private val beanList = arrayListOf<Treatedto>()

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

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): YYDS {
        return YYDS(R.layout.chequeedto.inflate(parent))
    }

    override fun getItemCount(): Int {
        return beanList.size
    }

    override fun onBindViewHolder(holder: YYDS, position: Int) {
        val binding = ChequeedtoBinding.bind(holder.itemView)
        val bean = beanList[position]
        val context = holder.itemView.context
        binding.lightedto.text = bean.tittle
        binding.shiftedto.isVisible = bean.isSelect
        if (bean.isSelect) {
            binding.lightedto.setTextColor(ContextCompat.getColor(context, R.color.exemptionedto))
            binding.lightedto.setTextSize(Dimension.SP, 18f)
        } else {
            binding.lightedto.setTextColor(ContextCompat.getColor(context, R.color.publisheredto))
            binding.lightedto.setTextSize(Dimension.SP, 16f)
        }
        binding.root.setOnClickListener {
            click.invoke(bean)
        }
    }

    @SuppressLint("NotifyDataSetChanged")
    fun setData(list: List<Treatedto>) {
        beanList.clear()
        beanList.addAll(list)
        notifyDataSetChanged()
    }
}