package mudslingingic.hackic.thanksic

import android.content.Context
import android.view.ViewGroup
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.easy.clean.R
import com.easy.clean.databinding.RhapsodyicBinding
import heartburnic.Chairic
import tooic.fatalityic.redic.speckledic.hankeringic.Resuscitateic.inflate
import com.chad.library.adapter4.BaseQuickAdapter

data class BatteryInfoBean(
    var tvValue: String,
    val title: String,
)

class Pusic : BaseQuickAdapter<List<BatteryInfoBean>, Chairic>() {

    var initSub: Boolean = false
    val subAdapter = SubAdapter()

    override fun onBindViewHolder(
        holder: Chairic,
        position: Int,
        item: List<BatteryInfoBean>?
    ) {
        item ?: return
        if (!initSub) {
            initSub = true
            val recyclerView = holder.itemView.findViewById<RecyclerView>(R.id.callingic)
            recyclerView.layoutManager = GridLayoutManager(holder.itemView.context, 2)
            recyclerView.adapter = subAdapter
        }
        subAdapter.submitList(item)
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): Chairic {
        return Chairic(R.layout.respiratoryic.inflate(parent))
    }


    inner class SubAdapter : BaseQuickAdapter<BatteryInfoBean, Chairic>() {
        override fun onBindViewHolder(
            holder: Chairic,
            position: Int,
            item: BatteryInfoBean?
        ) {
            item ?: return

            val binding = RhapsodyicBinding.bind(holder.itemView)
//            binding.ladleic.setImageResource(item.icon)
            binding.heckleric.text = item.tvValue
            binding.jobic.text = item.title

        }

        override fun onCreateViewHolder(
            context: Context,
            parent: ViewGroup,
            viewType: Int
        ): Chairic {
            return Chairic(R.layout.rhapsodyic.inflate(parent))
        }
    }
}