package pxds.etmo

import android.animation.ValueAnimator
import android.content.Intent
import android.view.animation.LinearInterpolator
import androidx.activity.OnBackPressedCallback
import com.test.basd.supercleanermax.R
import com.test.basd.supercleanermax.databinding.DhmsusBinding
import pxds.lmmd.zmwf.Bpfw
import pxds.lmmd.zmwf.Khko.setTrackedOnClickListener
import pxds.lmmd.zmwf.Khko.string
import pxds.lmmd.zmwf.jyyf.hwbn.wzxb.Utdc

class Vryl : Bpfw<DhmsusBinding>() {

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

    var isplay = 0

    override val isLightMode = true

    override fun onPermissionsResult(isGranted: Boolean) {
        if (isGranted) {
            isplay += 1
            if (isplay == 1) {
                playLottie()
            }
        } else {
            finishToMain()
        }
    }

    override fun onStart() {
        super.onStart()
        checkPermission()
    }

    override fun initView() {
        binding.vhddhup.setTrackedOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
        onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
            override fun handleOnBackPressed() {
                Utdc.showInterstitialAd(this@Vryl) {
                    finishToMain()
                }
            }

        })
    }

    private fun playLottie() {
        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()
        }
        binding.qmpntel.imageAssetsFolder = R.string.ޠޢލޏޘ_D.string()
        binding.qmpntel.setAnimation(R.string.ޒރޛޒޢ_D.string())
        binding.qmpntel.playAnimation()
        binding.root.postDelayed({
            Utdc.showInterstitialAd(this) {
                startActivity(Intent(this, Bihk::class.java))
                finish()
            }

        }, 5000)
    }
}