package com.test.basd.supercleanermax.activity

import android.content.Intent
import android.graphics.Color
import com.blankj.utilcode.util.BarUtils
import com.test.basd.supercleanermax.databinding.ActivityLayoutGuestBinding
import com.test.basd.supercleanermax.helps.BaseActivity
import com.test.basd.supercleanermax.helps.ConfigHelper
import kotlin.random.Random

/**
 * 引导动画页面
 */
class GuestActivity : BaseActivity<ActivityLayoutGuestBinding>() {

    override val binding: ActivityLayoutGuestBinding by lazy {
        ActivityLayoutGuestBinding.inflate(layoutInflater)
    }
    private var mProgress = 0

    override fun initView() {
        BarUtils.setStatusBarLightMode(this, true)
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
        ConfigHelper.ifGuest = true
        binding.idLottie.imageAssetsFolder = "sao_smax_miao/images/"
        binding.idLottie.setAnimation("sao_smax_miao/data.json")
        binding.idLottie.playAnimation()
        loadPro()
    }


    private fun loadPro() {
        if (mProgress >= 100) {
            binding.idSJindu.progress = mProgress
            startActivity(Intent(this, CleanGuestActivity::class.java))
            finish()
            return
        }
        binding.idSJindu.postDelayed({
            mProgress += Random.nextInt(5)
            binding.idSJindu.progress = mProgress
            loadPro()
        }, 80)

    }


}