1
0
Fork 0

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

master
Colin Lee 2019-05-13 10:59:05 -05:00 committed by GitHub
parent e68d594bbb
commit 155353f0ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 11 deletions

View File

@ -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?) {