package com.test.basd.smartjunkcleaner.activity.speed

import android.animation.Animator
import android.content.Intent
import android.graphics.Color
import androidx.core.view.isVisible
import androidx.core.view.updatePadding
import com.blankj.utilcode.util.BarUtils
import com.test.basd.smartjunkcleaner.databinding.ActivityLayoutSpeedBinding
import com.test.basd.smartjunkcleaner.helps.BaseActivity
import com.test.basd.smartjunkcleaner.view.AFunOb.BATTERY_OPTIMIZER

class BatteryOptimizerActivity : BaseActivity<ActivityLayoutSpeedBinding>() {


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

    override fun initView() {
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
        binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
        binding.idOneLottie.imageAssetsFolder = "dian_sjunk_chi/images/"
        binding.idOneLottie.setAnimation("dian_sjunk_chi/data.json")
        binding.idOneLottie.playAnimation()
        binding.root.postDelayed({
            binding.idOneLottie.isVisible = false
            binding.idScaning.text = "Optimizing"

            playRocket()
        }, 3000)
    }



    private fun playRocket() {
        binding.idRocket.imageAssetsFolder = "battery_sjunk_save/images/"
        binding.idRocket.setAnimation("battery_sjunk_save/data.json")
        binding.idRocket.playAnimation()
        binding.idRocket.addAnimatorListener(object : Animator.AnimatorListener {
            override fun onAnimationStart(p0: Animator) {

            }

            override fun onAnimationEnd(p0: Animator) {
                startActivity(Intent(this@BatteryOptimizerActivity, SpeedFinishActivity::class.java).putExtra("type", BATTERY_OPTIMIZER))
                finish()
            }

            override fun onAnimationCancel(p0: Animator) {

            }

            override fun onAnimationRepeat(p0: Animator) {

            }

        })
    }
}