package com.app.input.inputaura.lmyfvfs

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.os.CountDownTimer
import android.widget.ProgressBar
import com.ad.toponlibrary.AdManager
import com.app.input.inputaura.kfsdfbsd.IutFhfg
import com.app.input.inputaura.R
import kotlin.math.roundToInt


/**
 * 不要修改启动页继承Activity这点
 */
class HinDng : Activity() {

    private lateinit var progressBar: ProgressBar
    private var countTime = 15000L
    private lateinit var timer: CountDownTimer

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.mgihd)
        IutFhfg.initFullScreen(this, true)
        progressBar = findViewById<ProgressBar>(R.id.nova_progress)

        init()

    }

    private fun init() {
        timer = AdManager.showWelcomeAd(this, countTime,
            countAction = { millisUntilFinished ->
                val percentage: Float = 100 - millisUntilFinished.toFloat() / countTime * 100
                val round = percentage.roundToInt()
                progressBar.progress = round
            },
            goMain = {
                progressBar.progress = 100
                toHome()
        })
        timer.start()
    }

    private fun toHome() {
        startActivity(Intent(this, HiyFg::class.java))
        finish()
    }

    override fun onDestroy() {
        super.onDestroy()
        timer.cancel()
    }


}