package com.base.superfilemanager.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.base.superfilemanager.databinding.ActivityLayoutSpeedBinding
import com.base.superfilemanager.helps.BaseActivity
import com.base.superfilemanager.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_super_chi/images/"
        binding.idOneLottie.setAnimation("dian_super_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_super_save/images/"
        binding.idRocket.setAnimation("battery_super_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) {

            }

        })
    }
}