For #2449: App crashes when switching themes (#2450)

nightly-build-test
Colin Lee 5 years ago committed by GitHub
parent e68d594bbb
commit 155353f0ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -167,17 +167,20 @@ class HomeFragment : Fragment(), CoroutineScope {
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
val state = sessionControlComponent.stateObservable.blockingFirst()
outState.putParcelableArrayList(
KEY_TABS,
ArrayList(state.tabs)
)
outState.putParcelableArrayList(
KEY_COLLECTIONS,
ArrayList(state.collections)
)
val modeInt = if (state.mode is Mode.Private) 0 else 1
outState.putInt(KEY_MODE, modeInt)
// This can get called before onCreateView, before the component is defined
view?.let {
val state = sessionControlComponent.stateObservable.blockingFirst()
outState.putParcelableArrayList(
KEY_TABS,
ArrayList(state.tabs)
)
outState.putParcelableArrayList(
KEY_COLLECTIONS,
ArrayList(state.collections)
)
val modeInt = if (state.mode is Mode.Private) 0 else 1
outState.putInt(KEY_MODE, modeInt)
}
}
override fun onViewStateRestored(savedInstanceState: Bundle?) {

Loading…
Cancel
Save