package com.base.appzxhy.ui.main

import android.annotation.SuppressLint
import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.base.appzxhy.BuildConfig
import com.base.appzxhy.R
import com.base.appzxhy.databinding.ItemYuan2Binding
import com.base.appzxhy.utils.XmlEx.inflate
import com.chad.library.adapter4.BaseQuickAdapter
import kotlin.random.Random

class YuanAdapter2 : BaseQuickAdapter<Array<String>, YuanAdapter2.AAA>() {

    var cleanClick: (() -> Unit)? = null

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

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(holder: AAA, position: Int, item: Array<String>?) {
        item ?: return
        val binding = ItemYuan2Binding.bind(holder.itemView)

        if (BuildConfig.DEBUG) {
            binding.tvCleanSize.text = "%.2f".format(Random.nextFloat() * Random.nextInt(1, 10))
            binding.tvCleanSizeUnit.text = "GB Found"
        }

        binding.tvSize2.text = item[0]
        binding.tvSize1.text = item[1]


        binding.fl.setOnClickListener {
            cleanClick?.invoke()
        }
        binding.tvClean.setOnClickListener {
            cleanClick?.invoke()
        }
    }

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


}