package importantedto.appliededto.surgeonedto.promiseedto.rapeedto

import android.content.Intent
import android.widget.Toast
import androidx.activity.addCallback
import androidx.lifecycle.lifecycleScope
import com.base.datarecovery.databinding.CreededtoBinding
import importantedto.admireedto.sweptedto.Differenceedto
import importantedto.afteredto.constitutionaledto.Murderedto
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.random.Random

class Eyebrowedto : Murderedto<CreededtoBinding>() {

    override val binding: CreededtoBinding by lazy {
        CreededtoBinding.inflate(layoutInflater)
    }
    private var job: Job? = null

    override fun initView() {

    }

    fun jumpJob() = lifecycleScope.launch {
        delay(Random.nextLong(3000, 4500))
        Differenceedto.admobMaxShowInterstitialAd(this@Eyebrowedto) {
            startActivity(Intent(this@Eyebrowedto, Boardedto::class.java))
            finish()
        }
    }

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

    override fun onResume() {
        super.onResume()
        if (job?.isActive == false || job == null) {
            job = jumpJob()
        }
    }

    override fun onPause() {
        super.onPause()
        job?.cancel()
        job = null
    }

}