package pxds.etmo

import android.animation.ValueAnimator
import android.content.Intent
import android.graphics.Color
import android.view.animation.LinearInterpolator
import androidx.core.animation.doOnEnd
import androidx.core.view.updatePadding
import com.blankj.utilcode.util.BarUtils
import com.test.basd.supercleanermax.R
import com.test.basd.supercleanermax.databinding.EvyzjxBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import pxds.dlpf.buoz.fico.Dsce
import pxds.lmmd.zmwf.Bpfw
import pxds.lmmd.zmwf.Khko.string
import pxds.lmmd.zmwf.Oejm
import pxds.lmmd.zmwf.Uawv
import pxds.lmmd.zmwf.jyyf.hwbn.wzxb.Utdc
import java.io.File
import kotlin.random.Random

class Svyw : Bpfw<EvyzjxBinding>() {

    override val binding: EvyzjxBinding by lazy {
        EvyzjxBinding.inflate(layoutInflater)
    }

    private val intentSize by lazy {
        intent.getLongExtra(R.string.ޜޑސއޗ_D.string(), -1)
    }

    var isDeleSuc = false

    private val listPath by lazy {
        intent.getStringArrayExtra(R.string.ފޗތށޞ_D.string()) ?: arrayOf()
    }

    private var size = 0L

    override val isLightMode = true

    private fun playAnm() {
        ValueAnimator.ofFloat(0f, 360f).run {
            duration = 1000
            repeatMode = ValueAnimator.RESTART
            repeatCount = ValueAnimator.INFINITE
            interpolator = LinearInterpolator()
            addUpdateListener {
                binding.hacbtuk.rotation = it.animatedValue as Float
            }
            start()
        }
        ValueAnimator.ofInt(0, 100).run {
            duration = Random.nextLong(7000, 8000)
            interpolator = LinearInterpolator()
            addUpdateListener {
                binding.lcyacvs.text = R.string.ދޙޅޤޝ_D.string((it.animatedValue as Int).toString())
            }
            doOnEnd {
                Utdc.showInterstitialAd(this@Svyw) {
                    startActivity(Intent(this@Svyw, Iqnb::class.java).putExtra(R.string.ޣޟމޅކ_D.string(), Dsce.JUNK_CLEANER).putExtra(R.string.ޠޜޚސޙ_D.string(), intentSize))
                    finish()
                }

            }
            start()
        }
        ValueAnimator.ofFloat(0f, 360f).run {
            duration = 1000
            repeatMode = ValueAnimator.RESTART
            repeatCount = ValueAnimator.INFINITE
            interpolator = LinearInterpolator()
            addUpdateListener {
                binding.zgfyyfj.rotation = it.animatedValue as Float
            }
            start()
        }
        ValueAnimator.ofFloat(0f, 360f).run {
            duration = 1000
            repeatMode = ValueAnimator.RESTART
            repeatCount = ValueAnimator.INFINITE
            interpolator = LinearInterpolator()
            addUpdateListener {
                binding.ubdvvrn.rotation = it.animatedValue as Float
            }
            start()
        }
        ValueAnimator.ofFloat(0f, 360f).run {
            duration = 1000
            repeatMode = ValueAnimator.RESTART
            repeatCount = ValueAnimator.INFINITE
            interpolator = LinearInterpolator()
            addUpdateListener {
                binding.tmzkbkq.rotation = it.animatedValue as Float
            }
            start()
        }
    }

    override fun initView() {
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
        binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
        Uawv.junkSizeClean = Uawv.junkSizeClean+intentSize
        MainScope().launch(Dispatchers.IO) {
            try {
                Oejm.fileList.clear()
                listPath.forEach {
                    val file = File(it)
                    if (Oejm.deleteFile(file)) {
                        isDeleSuc = true
                    }

                }
            } catch (_: Exception) {
            } finally {

            }
        }
        playAnm()
    }
}