package com.zxhy.hfilemanagermaster

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import com.example.hfilemanagermaster.R
import com.example.hfilemanagermaster.databinding.ActivityHlaunchBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@SuppressLint("CustomSplashScreen")
class HLaunchActivity : AppCompatActivity() {
    private lateinit var binding: ActivityHlaunchBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        binding = ActivityHlaunchBinding.inflate(layoutInflater)
//        setContentView(R.layout.activity_hlaunch)
        setContentView(binding.root)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        lifecycleScope.launch(Dispatchers.Main) {
            var i = 0
            while (i <= 100) {
                binding.progressH.progress = i
                i++
                delay(10)
            }
            val intent = Intent(this@HLaunchActivity, OverviewActivity::class.java)
            startActivity(intent)
            finish()
        }
    }
}
