Fixed crash when changing theme

This commit is contained in:
ByteHamster 2019-12-09 23:51:43 +01:00
parent 89128fbd62
commit a1c3ae6d0e

View file

@ -36,8 +36,8 @@ class GeneralSettingsActivity : K9Activity(), OnPreferenceStartScreenCallback, S
add(R.id.generalSettingsContainer, GeneralSettingsFragment.create())
}
} else {
searchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY) ?: error("Missing instance state")
searchEnabled = savedInstanceState.getBoolean(KEY_SEARCH_ENABLED)
searchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY, "")
searchEnabled = savedInstanceState.getBoolean(KEY_SEARCH_ENABLED, false)
}
}
@ -47,9 +47,11 @@ class GeneralSettingsActivity : K9Activity(), OnPreferenceStartScreenCallback, S
}
override fun onSaveInstanceState(outState: Bundle) {
outState.putString(KEY_SEARCH_QUERY, searchPreferenceActionView.query.toString())
outState.putBoolean(KEY_SEARCH_ENABLED, !searchPreferenceActionView.isIconified)
searchPreferenceActionView.onBackPressed()
if (::searchPreferenceActionView.isInitialized) {
outState.putString(KEY_SEARCH_QUERY, searchPreferenceActionView.query.toString())
outState.putBoolean(KEY_SEARCH_ENABLED, !searchPreferenceActionView.isIconified)
searchPreferenceActionView.onBackPressed()
}
super.onSaveInstanceState(outState)
}