fix activity restart after theme switch
This commit is contained in:
parent
25a73620a9
commit
3b475e8461
|
@ -85,6 +85,8 @@ class PreferencesActivity : BaseActivity(), SharedPreferences.OnSharedPreference
|
||||||
.replace(R.id.fragment_container, fragment)
|
.replace(R.id.fragment_container, fragment)
|
||||||
.commit()
|
.commit()
|
||||||
|
|
||||||
|
restartActivitiesOnExit = intent.getBooleanExtra("restart", false)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -119,9 +121,9 @@ class PreferencesActivity : BaseActivity(), SharedPreferences.OnSharedPreference
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||||
when (key) {
|
when (key) {
|
||||||
"appTheme" -> {
|
"appTheme" -> {
|
||||||
val theme = sharedPreferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT)
|
val theme = sharedPreferences.getNonNullString("appTheme", ThemeUtils.APP_THEME_DEFAULT)
|
||||||
Log.d("activeTheme", theme)
|
Log.d("activeTheme", theme)
|
||||||
ThemeUtils.setAppNightMode(theme!!, this)
|
ThemeUtils.setAppNightMode(theme, this)
|
||||||
restartActivitiesOnExit = true
|
restartActivitiesOnExit = true
|
||||||
|
|
||||||
// recreate() could be used instead, but it doesn't have an animation B).
|
// recreate() could be used instead, but it doesn't have an animation B).
|
||||||
|
|
Loading…
Reference in New Issue