package com.apps.sketchmaster.view

import android.content.Intent
import android.os.Bundle
import android.os.CountDownTimer
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AppCompatActivity
import com.ad.maxlibrary.MaxInitManager
import com.ad.maxlibrary.MaxManager
import com.ad.maxlibrary.WelComManager
import com.apps.sketchmaster.R
import com.apps.sketchmaster.databinding.ActivityLauncherBinding
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.load.resource.bitmap.RoundedCorners

class LauncherActivity : AppCompatActivity() {
    private lateinit var binding: ActivityLauncherBinding
    private lateinit var countDownTimer: CountDownTimer
    private val timer = 12000L
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding=ActivityLauncherBinding.inflate(layoutInflater)
        setContentView(binding.root)
        Glide.with(this).load(R.mipmap.ic_launcher_round).transform(RoundedCorners(20)).into(binding.logo)

        countDownTimer = WelComManager.initTimer(this, timer, { millisUntilFinished ->
            val v: Float =
                100 - millisUntilFinished.toFloat() / timer * 100
            val v1 = v.toInt()
            binding.progressbar.progress =  v1

        }) {
            startActivity(Intent(this@LauncherActivity, MainViewActivity::class.java))
            finish()
        }
    }
    override fun onDestroy() {
        super.onDestroy()
        countDownTimer.cancel()
    }
}