fix activity restart after theme switch

This commit is contained in:
Conny Duck 2018-11-18 12:29:11 +01:00
parent 25a73620a9
commit 3b475e8461

View file

@ -85,6 +85,8 @@ class PreferencesActivity : BaseActivity(), SharedPreferences.OnSharedPreference
.replace(R.id.fragment_container, fragment)
.commit()
restartActivitiesOnExit = intent.getBooleanExtra("restart", false)
}
override fun onResume() {
@ -119,9 +121,9 @@ class PreferencesActivity : BaseActivity(), SharedPreferences.OnSharedPreference
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
when (key) {
"appTheme" -> {
val theme = sharedPreferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT)
val theme = sharedPreferences.getNonNullString("appTheme", ThemeUtils.APP_THEME_DEFAULT)
Log.d("activeTheme", theme)
ThemeUtils.setAppNightMode(theme!!, this)
ThemeUtils.setAppNightMode(theme, this)
restartActivitiesOnExit = true
// recreate() could be used instead, but it doesn't have an animation B).