package com.base.filerecoveryrecyclebin.activity.guide

import android.content.Intent
import android.graphics.Color
import androidx.core.view.isVisible
import androidx.core.view.updatePadding
import com.base.filerecoveryrecyclebin.activity.MainActivity
import com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunkActivity
import com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
import com.base.filerecoveryrecyclebin.bean.ConstObject.isCLeanGuide
import com.base.filerecoveryrecyclebin.databinding.ActivityLayoutCleanGuideBinding
import com.base.filerecoveryrecyclebin.help.BaseActivity
import com.base.filerecoveryrecyclebin.utils.BarUtils
import kotlin.random.Random

class CleanGuideActivity : BaseActivity<ActivityLayoutCleanGuideBinding>() {
    override val binding: ActivityLayoutCleanGuideBinding by lazy {
        ActivityLayoutCleanGuideBinding.inflate(layoutInflater)
    }

    override fun initView() {
        BarUtils.setStatusBarLightMode(this, true)
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
        binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
        loadPro()
        isCLeanGuide=true
        AdmobMaxHelper.admobMaxShowNativeAd(this,binding.idFlNative)
    }

    override fun initListener() {
        binding.idClean.setOnClickListener {
            startActivity(Intent(this, ScanJunkActivity::class.java))
            finish()
        }
        binding.idTvSkip.setOnClickListener {
            startActivity(Intent(this, MainActivity::class.java))
            finish()
        }
    }
    private var mProess = 0
    private fun loadPro() {
        if (mProess >= 100) {
            binding.idProcess.progress = mProess
            binding.idLl01.isVisible=false
            binding.idLl02.isVisible=true
            binding.idTvSkip.isVisible=true
            return
        }
        binding.root.postDelayed(Runnable {
            mProess += Random.nextInt(5)
            binding.idProcess.progress = mProess
            loadPro()
        }, 80)

    }
}