package com.base.easyfilemanager.notificationclean

import android.content.Intent
import android.graphics.Color
import androidx.activity.OnBackPressedCallback
import androidx.core.view.updatePadding
import com.base.easyfilemanager.databinding.ActivityLayoutTionGuestBinding
import com.base.easyfilemanager.helps.BaseActivity
import com.base.easyfilemanager.helps.ads.AdmobUtils
import com.base.easyfilemanager.utils.BarUtils
import com.base.easyfilemanager.utils.SPUtils
import kotlin.random.Random

class NotificationGuestActivity : BaseActivity<ActivityLayoutTionGuestBinding>() {


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


    override fun initView() {
        BarUtils.setStatusBarLightMode(this, true)
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
        binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
        binding.idTzGuest.imageAssetsFolder = "easy_tz_scan/images/"
        binding.idTzGuest.setAnimation("easy_tz_scan/data.json")
        binding.idTzGuest.playAnimation()
        SPUtils.getInstance().put("notification_guest", true)
        binding.root.postDelayed({
            AdmobUtils.showInterstitialAd(this) {
                startActivity(Intent(this, NotificationCleanActivity::class.java))
                finish()
            }
        }, Random.nextLong(2500, 4000))
        binding.idTvTryNow.setOnClickListener {
            startActivity(Intent(this, NotificationCleanActivity::class.java))
            finish()
        }
        binding.idTGuanbi.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
        onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
            override fun handleOnBackPressed() {
                AdmobUtils.showInterstitialAd(this@NotificationGuestActivity) {
                    finishToMain()
                }

            }
        })
    }

}