Skip to content
Snippets Groups Projects
Verified Commit 18f07e27 authored by Sebastian's avatar Sebastian
Browse files

Rename bundle variable name and value

parent 15000777
No related branches found
No related tags found
1 merge request!113Reset UI to initial state with fresh lifecycle
Pipeline #11663 passed
......@@ -64,7 +64,7 @@ class MainActivity : AppCompatActivity(), ActivityResultCallback<ActivityResult>
companion object {
private val LOG = getLogger(MainActivity::class.java)
const val BUNDLE_LIFECYCLE_BEYOND_NOT_STARTED = "LIFECYCLE_BEYOND_NOT_STARTED"
const val BUNDLE_LIFECYCLE_HAS_STARTED = "LIFECYCLE_HAS_STARTED"
}
private val viewModel: MailboxViewModel by viewModels()
......@@ -84,8 +84,7 @@ class MainActivity : AppCompatActivity(), ActivityResultCallback<ActivityResult>
// Check if the app has been restored with a UI from an old lifecycle while the app has been
// restarted with a new process and lifecycle. In that case, go back to the init fragment.
if (savedInstanceState != null) {
val hadBeenStartedOnSave =
savedInstanceState.getBoolean(BUNDLE_LIFECYCLE_BEYOND_NOT_STARTED)
val hadBeenStartedOnSave = savedInstanceState.getBoolean(BUNDLE_LIFECYCLE_HAS_STARTED)
if (viewModel.lifecycleState.value == NOT_STARTED && hadBeenStartedOnSave) {
nav.navigate(actionGlobalInitFragment())
}
......@@ -144,9 +143,8 @@ class MainActivity : AppCompatActivity(), ActivityResultCallback<ActivityResult>
// in the background and gets restored from the recent app list after wiping and
// stopping has already completed. In this case onSaveInstanceState() has written
// true to the bundle.
val savedBeyondNotStarted =
savedInstanceState.getBoolean(BUNDLE_LIFECYCLE_BEYOND_NOT_STARTED)
if (!hasDb && savedBeyondNotStarted) {
val hadBeenStartedOnSave = savedInstanceState.getBoolean(BUNDLE_LIFECYCLE_HAS_STARTED)
if (!hasDb && hadBeenStartedOnSave) {
finish()
startActivity(Intent(this, WipeCompleteActivity::class.java))
return
......@@ -170,7 +168,7 @@ class MainActivity : AppCompatActivity(), ActivityResultCallback<ActivityResult>
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putBoolean(
BUNDLE_LIFECYCLE_BEYOND_NOT_STARTED,
BUNDLE_LIFECYCLE_HAS_STARTED,
viewModel.lifecycleState.value != NOT_STARTED
)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment