package com.zxhyis.toolss.ui.page.speed

import android.animation.Animator
import android.content.Intent
import android.graphics.Color
import androidx.core.view.updatePadding
import com.blankj.utilcode.util.BarUtils
import com.zxhyis.toolss.ad.AdmobUtils
import com.zxhyis.toolss.base.TopActivity
import com.zxhyis.toolss.databinding.ActivityLayoutSpeedFinishBinding
import com.zxhyis.toolss.ui.page.result.ResultActivity

class SpeedFinishActivity : TopActivity<ActivityLayoutSpeedFinishBinding>() {
    override fun getViewBinding1(): ActivityLayoutSpeedFinishBinding {
        return ActivityLayoutSpeedFinishBinding.inflate(layoutInflater)
    }

    override fun init() {
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
        val type = intent.getStringExtra("type")
        vb.root.updatePadding(top = BarUtils.getStatusBarHeight())

        vb.idSpeedFinish.addAnimatorListener(object : Animator.AnimatorListener {
            override fun onAnimationStart(p0: Animator) {

            }

            override fun onAnimationEnd(p0: Animator) {
                AdmobUtils.showInterstitialAd(this@SpeedFinishActivity) {
                    startActivity(
                        Intent(
                            this@SpeedFinishActivity,
                            ResultActivity::class.java
                        ).putExtra("from", type)
                    )
                    finish()
                }

            }

            override fun onAnimationCancel(p0: Animator) {

            }

            override fun onAnimationRepeat(p0: Animator) {

            }

        })
    }
}