package pxds.hpls.xkxo

import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.blankj.utilcode.util.SPUtils
import com.test.basd.supercleanermax.R
import com.test.basd.supercleanermax.databinding.SjxcmxBinding
import pxds.dlpf.buoz.fico.Dsce.APP_MANAGER
import pxds.dlpf.buoz.fico.Dsce.BATTERY_INFO
import pxds.dlpf.buoz.fico.Dsce.JUNK_CLEANER
import pxds.dlpf.buoz.fico.Dsce.LARGE_FILE_CLEANER
import pxds.dlpf.buoz.fico.Dsce.NETWORK_TRAFFIC
import pxds.dlpf.buoz.fico.Dsce.NOTIFICATION_CLEANER
import pxds.dlpf.buoz.fico.Dsce.PHOTO_COMPRESS
import pxds.dlpf.buoz.fico.Dsce.RECENT_APP_USAGE
import pxds.dlpf.buoz.fico.Dsce.SIMILAR_PHOTOS
import pxds.dlpf.buoz.fico.Ipnk.inflate
import pxds.lmmd.zmwf.Khko.setTrackedOnClickListener
import pxds.lmmd.zmwf.Khko.string
import java.util.Collections

class Obzz(val click: (name: String) -> Unit) : RecyclerView.Adapter<Obzz.JJJ>() {

    val list = arrayListOf(
        Fun(JUNK_CLEANER, R.mipmap.jrszgjth, R.string.ޔޓޟބޖ_D.string(), R.string.ހފޡޤޡ_D.string()), Fun(PHOTO_COMPRESS, R.mipmap.onnpagee, R.string.ތވށޅޖ_D.string(), R.string.ޓލގޖޅ_D.string()), Fun(LARGE_FILE_CLEANER, R.mipmap.qkrgpvzn, R.string.ޠހޅރޒ_D.string(), R.string.ހފޡޤޡ_D.string()), Fun(BATTERY_INFO, R.mipmap.gilqycau, R.string.ޞޟށޘޅ_D.string(), R.string.ޔޓގޥވ_D.string()), Fun(
            APP_MANAGER, R.mipmap.aokjzubh, R.string.މޣމމޣ_D.string(), R.string.ޔޓގޥވ_D.string()
        ), Fun(
            SIMILAR_PHOTOS, R.mipmap.nzyhblgp, R.string.ޏދށސޔ_D.string(), R.string.ހފޡޤޡ_D.string()
        ), Fun(
            NOTIFICATION_CLEANER, R.mipmap.hxdylsvj, R.string.ޅނޞޑޒ_D.string(), R.string.ޔޓގޥވ_D.string()
        ), Fun(RECENT_APP_USAGE, R.mipmap.qdurhfnw, R.string.ޖވޣދޥ_D.string(), R.string.އއފޥޓ_D.string()), Fun(
            NETWORK_TRAFFIC, R.mipmap.vowqbazu, R.string.ޠށޅޠޗ_D.string(), R.string.އއފޥޓ_D.string()
        )
    )

    fun updateListPosition() {

        val lastUsejunkcleaner = SPUtils.getInstance().getLong(R.string.ޞލޙޤޠ_D.string(), 0)

        if ((System.currentTimeMillis() - lastUsejunkcleaner) >= 60 * 5 * 1000) {

        } else {

            Collections.rotate(list, list.size - 1)
        }
    }

    class JJJ(view: View) : ViewHolder(view)

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

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

    override fun onBindViewHolder(holder: JJJ, position: Int) {
        val data = list[position]
        val context = holder.itemView.context
        val binding = SjxcmxBinding.bind(holder.itemView)
        binding.yukpgfw.setImageDrawable(ContextCompat.getDrawable(context, data.icon))
        binding.ljhubwr.text = data.name
        binding.snmfref.text = data.des
        binding.gitfktc.text = data.button
        binding.gitfktc.setTrackedOnClickListener {
            click.invoke(data.name)
        }
    }

    fun removeItem(name: String) {
        list.removeIf { it.name == name }
        notifyDataSetChanged()
    }

    data class Fun(
        val name: String = R.string.ށޓސހކ_D.string(), val icon: Int = 0, val des: String = R.string.ށޓސހކ_D.string(), val button: String = R.string.ށޓސހކ_D.string(), )

}