package aicg.wipf.tzxq

import aicg.wipf.rxxn.Ayhm.inflate
import aicg.wipf.rxxn.Qczw.APP_MANAGER
import aicg.wipf.rxxn.Qczw.BATTERY_INFO
import aicg.wipf.rxxn.Qczw.JUNK_CLEANER
import aicg.wipf.rxxn.Qczw.LARGE_FILE_CLEANER
import aicg.wipf.rxxn.Qczw.NETWORK_TRAFFIC
import aicg.wipf.rxxn.Qczw.NOTIFICATION_CLEANER
import aicg.wipf.rxxn.Qczw.PHOTO_COMPRESS
import aicg.wipf.rxxn.Qczw.RECENT_APP_USAGE
import aicg.wipf.rxxn.Qczw.SIMILAR_PHOTOS
import aicg.wipf.vzuj.Kmqp.setTrackedOnClickListener
import aicg.wipf.vzuj.Kmqp.string
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.smartjunkcleaner.R
import com.test.basd.smartjunkcleaner.databinding.VueulkBinding
import java.util.Collections

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

    val list = arrayListOf(
        Fun(JUNK_CLEANER, R.mipmap.uoujcpuh, R.string.ރބޕޙޟ_D.string(), R.string.ޏގޥނޗ_D.string()), Fun(PHOTO_COMPRESS, R.mipmap.ixrjveko, R.string.ޓޝޖޕޕ_D.string(), R.string.އލއނޑ_D.string()), Fun(LARGE_FILE_CLEANER, R.mipmap.anggestt, R.string.އޙޤޟޕ_D.string(), R.string.ޏގޥނޗ_D.string()), Fun(BATTERY_INFO, R.mipmap.rfupufkd, R.string.ރގފގހ_D.string(), R.string.ޑއޢޓޛ_D.string()), Fun(
            APP_MANAGER, R.mipmap.xmnaizaq, R.string.ޣޙޛޠޕ_D.string(), R.string.ޑއޢޓޛ_D.string()
        ), Fun(
            SIMILAR_PHOTOS, R.mipmap.kgeksqpy, R.string.ޜށލޢޑ_D.string(), R.string.ޏގޥނޗ_D.string()
        ), Fun(
            NOTIFICATION_CLEANER, R.mipmap.hzdvbace, R.string.ގޠކޏޗ_D.string(), R.string.ޑއޢޓޛ_D.string()
        ), Fun(RECENT_APP_USAGE, R.mipmap.tafbopah, R.string.ވޖޛޛކ_D.string(), R.string.ޚޓތދދ_D.string()), Fun(
            NETWORK_TRAFFIC, R.mipmap.kvbyajoa, R.string.ޚޖޢލޝ_D.string(), R.string.ޚޓތދދ_D.string()
        )
    )

    fun updateListPostion() {

        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.vueulk.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 = VueulkBinding.bind(holder.itemView)
        binding.xgftith.setImageDrawable(ContextCompat.getDrawable(context, data.icon))
        binding.flvcwej.text = data.name
        binding.wsdplnq.text = data.des
        binding.jbazoow.text = data.button
        binding.jbazoow.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(), )

}