Skip to content

Commit

Permalink
[FIX/#163] 스플래쉬뷰 로직 onResume 대응
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchbreeze committed Oct 31, 2024
1 parent 8288baf commit 7c419b9
Showing 1 changed file with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import com.google.android.play.core.appupdate.AppUpdateOptions
import com.google.android.play.core.install.model.AppUpdateType.IMMEDIATE
import com.google.android.play.core.install.model.UpdateAvailability.UPDATE_AVAILABLE
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kr.genti.core.base.BaseActivity
Expand All @@ -47,11 +46,16 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_spl
super.onCreate(savedInstanceState)

setSystemWindowsTransparent()
checkAppUpdateAvailable()
observeAutoLoginState()
observeReissueTokenResult()
}

override fun onResume() {
super.onResume()

checkAppUpdateAvailable()
}

private fun setSystemWindowsTransparent() {
WindowCompat.setDecorFitsSystemWindows(window, false)
WindowInsetsControllerCompat(window, window.decorView).apply {
Expand Down Expand Up @@ -79,7 +83,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_spl

private fun isAppUpdateNeeded(appUpdateInfo: AppUpdateInfo) =
appUpdateInfo.updateAvailability() == UPDATE_AVAILABLE &&
appUpdateInfo.isUpdateTypeAllowed(IMMEDIATE)
appUpdateInfo.isUpdateTypeAllowed(IMMEDIATE)

private fun requestUpdate(appUpdateInfo: AppUpdateInfo) {
runCatching {
Expand All @@ -92,25 +96,23 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_spl
}

private fun observeAutoLoginState() {
viewModel.isAutoLogined.flowWithLifecycle(lifecycle).distinctUntilChanged()
.onEach { isAutoLogined ->
if (isAutoLogined) {
viewModel.postToReissueToken()
} else {
navigateTo<LoginActivity>()
}
}.launchIn(lifecycleScope)
viewModel.isAutoLogined.flowWithLifecycle(lifecycle).onEach { isAutoLogined ->
if (isAutoLogined) {
viewModel.postToReissueToken()
} else {
navigateTo<LoginActivity>()
}
}.launchIn(lifecycleScope)
}

private fun observeReissueTokenResult() {
viewModel.reissueTokenResult.flowWithLifecycle(lifecycle).distinctUntilChanged()
.onEach { isSuccess ->
if (isSuccess) {
navigateTo<MainActivity>()
} else {
navigateTo<LoginActivity>()
}
}.launchIn(lifecycleScope)
viewModel.reissueTokenResult.flowWithLifecycle(lifecycle).onEach { isSuccess ->
if (isSuccess) {
navigateTo<MainActivity>()
} else {
navigateTo<LoginActivity>()
}
}.launchIn(lifecycleScope)
}

private inline fun <reified T : Activity> navigateTo() {
Expand Down

0 comments on commit 7c419b9

Please sign in to comment.