package com.example.smart.ui.splash
|
|
|
import android.util.Log
|
import android.view.View
|
import androidx.activity.viewModels
|
import androidx.lifecycle.lifecycleScope
|
import com.example.basecore.BaseActivity
|
import com.example.basecore.util.SchemeUtils
|
import com.example.basecore.util.sysbar.StatusBarUtils
|
import com.example.smart.R
|
import com.example.smart.oss.OssService
|
import com.example.smart.util.StatusProvider
|
import com.example.smart.util.loginScheme
|
import com.example.smart.util.mainScheme
|
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.launch
|
|
class SplashActivity : BaseActivity() {
|
|
|
private lateinit var logoContainer: View
|
override fun getLayoutId() = R.layout.activity_splash
|
|
private val viewModel: SplashViewModel by viewModels()
|
|
|
override fun initData() {
|
// viewModel.requestOssKey()
|
// viewModel.bean.observe(this) {
|
// Log.e(
|
// "dh", "id = ${it.accessId}, secret = ${it.accessSecret}, " +
|
// "token = ${it.token}"
|
// )
|
// OssService.create(it.accessId, it.accessSecret, it.token, application)
|
// }
|
}
|
|
override fun initView() {
|
StatusBarUtils.transparentMode(this, true, isFullScreen = true)
|
|
lifecycleScope.launch {
|
logoContainer = findViewById(R.id.logo_container)
|
|
viewModel.callLoginStatus {
|
if (it == "未登录") {
|
StatusProvider.loginOut()
|
}
|
}
|
|
delay(2000)
|
// logoContainer.visibility = View.GONE
|
// delay(3000)
|
|
|
|
val router = if (StatusProvider.hasLogin()) {
|
mainScheme
|
} else {
|
loginScheme
|
}
|
|
|
SchemeUtils.openScheme(this@SplashActivity, router)
|
finish()
|
}
|
}
|
|
|
}
|