package com.base.datarecovery.activity.photomanager

import android.content.Intent
import android.view.View
import android.widget.Toast
import androidx.activity.addCallback
import androidx.lifecycle.lifecycleScope
import com.base.datarecovery.ads.AdmobMaxHelper
import com.base.datarecovery.databinding.ActivityScreenShotAnimationBinding
import com.base.datarecovery.help.BaseActivity
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.random.Random

class PhotoManagerAnimationActivity : BaseActivity<ActivityScreenShotAnimationBinding>() {

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

    override fun initView() {
        lifecycleScope.launch(Dispatchers.Main) {
            delay(Random.nextLong(4000, 4500))
            binding.lottie.visibility = View.INVISIBLE
            binding.lottieCompleted.visibility = View.VISIBLE
            binding.lottieCompleted.playAnimation()
            delay(1500)
            AdmobMaxHelper.admobMaxShowInterstitialAd(this@PhotoManagerAnimationActivity) {
                startActivity(Intent(this@PhotoManagerAnimationActivity, PhotoManagerActivity::class.java))
                finish()
            }
        }

    }

    override fun initListener() {
        super.initListener()
        onBackPressedDispatcher.addCallback {
            Toast.makeText(this@PhotoManagerAnimationActivity, "wait a moment", Toast.LENGTH_SHORT).show()
        }
    }

}