package com.test.basd.smartjunkcleaner.activity

import android.content.Intent
import android.graphics.Color
import com.blankj.utilcode.util.BarUtils
import com.test.basd.smartjunkcleaner.databinding.ActivityLayoutGuestBinding
import com.test.basd.smartjunkcleaner.helps.BaseActivity
import com.test.basd.smartjunkcleaner.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_sjunk_miao/images/"
        binding.idLottie.setAnimation("sao_sjunk_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)

    }


}