Skip to content

Commit

Permalink
Extract setting check logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Taewan-P committed May 20, 2024
1 parent fc9aa44 commit 332bfb7
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,7 @@ class HomeActivity : ComponentActivity() {
}
enableEdgeToEdge()
super.onCreate(savedInstanceState)

lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.CREATED) {
homeViewModel.event.collect { event ->
if (event == HomeViewModel.SplashEvent.OpenIntro) {
launchActivityAndExit(this@HomeActivity, StartScreenActivity::class.java)
}
}
}
}
checkForExistingSettings()

setContent {
GPTMobileTheme {
Expand All @@ -60,6 +51,18 @@ class HomeActivity : ComponentActivity() {
}
}

private fun checkForExistingSettings() {
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.CREATED) {
homeViewModel.event.collect { event ->
if (event == HomeViewModel.SplashEvent.OpenIntro) {
launchActivityAndExit(this@HomeActivity, StartScreenActivity::class.java)
}
}
}
}
}

private fun <T : Activity> launchActivityAndExit(context: Context, clazz: Class<T>) {
val intent = Intent(context, clazz)
startActivity(intent)
Expand Down

0 comments on commit 332bfb7

Please sign in to comment.