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 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> ...@@ -64,7 +64,7 @@ class MainActivity : AppCompatActivity(), ActivityResultCallback<ActivityResult>
companion object { companion object {
private val LOG = getLogger(MainActivity::class.java) 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() private val viewModel: MailboxViewModel by viewModels()
...@@ -84,8 +84,7 @@ class MainActivity : AppCompatActivity(), ActivityResultCallback<ActivityResult> ...@@ -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 // 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. // restarted with a new process and lifecycle. In that case, go back to the init fragment.
if (savedInstanceState != null) { if (savedInstanceState != null) {
val hadBeenStartedOnSave = val hadBeenStartedOnSave = savedInstanceState.getBoolean(BUNDLE_LIFECYCLE_HAS_STARTED)
savedInstanceState.getBoolean(BUNDLE_LIFECYCLE_BEYOND_NOT_STARTED)
if (viewModel.lifecycleState.value == NOT_STARTED && hadBeenStartedOnSave) { if (viewModel.lifecycleState.value == NOT_STARTED && hadBeenStartedOnSave) {
nav.navigate(actionGlobalInitFragment()) nav.navigate(actionGlobalInitFragment())
} }
...@@ -144,9 +143,8 @@ class MainActivity : AppCompatActivity(), ActivityResultCallback<ActivityResult> ...@@ -144,9 +143,8 @@ class MainActivity : AppCompatActivity(), ActivityResultCallback<ActivityResult>
// in the background and gets restored from the recent app list after wiping and // in the background and gets restored from the recent app list after wiping and
// stopping has already completed. In this case onSaveInstanceState() has written // stopping has already completed. In this case onSaveInstanceState() has written
// true to the bundle. // true to the bundle.
val savedBeyondNotStarted = val hadBeenStartedOnSave = savedInstanceState.getBoolean(BUNDLE_LIFECYCLE_HAS_STARTED)
savedInstanceState.getBoolean(BUNDLE_LIFECYCLE_BEYOND_NOT_STARTED) if (!hasDb && hadBeenStartedOnSave) {
if (!hasDb && savedBeyondNotStarted) {
finish() finish()
startActivity(Intent(this, WipeCompleteActivity::class.java)) startActivity(Intent(this, WipeCompleteActivity::class.java))
return return
...@@ -170,7 +168,7 @@ class MainActivity : AppCompatActivity(), ActivityResultCallback<ActivityResult> ...@@ -170,7 +168,7 @@ class MainActivity : AppCompatActivity(), ActivityResultCallback<ActivityResult>
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
outState.putBoolean( outState.putBoolean(
BUNDLE_LIFECYCLE_BEYOND_NOT_STARTED, BUNDLE_LIFECYCLE_HAS_STARTED,
viewModel.lifecycleState.value != NOT_STARTED viewModel.lifecycleState.value != NOT_STARTED
) )
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment