From eca29dbfd4cae7b051f79ce3cb93f7c55bf092aa Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 16 May 2020 13:14:13 +0300 Subject: [PATCH] fix activity restart upon profile theme change strangely, calling onSaveInstanceState at this time races with some other thing reacting to the change making fragment manager crash with "fragment transaction already in progress" regardless, Actvity.recreate() is designed just for this job --- .../ktnx/mobileledger/ui/activity/MainActivity.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index 27cc9eba..dace5c41 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -478,21 +478,14 @@ public class MainActivity extends ProfileThemedActivity { scheduleDataRetrievalIfStale(newValue); } private void profileThemeChanged() { - Bundle bundle = new Bundle(); - onSaveInstanceState(bundle); - storeThemeIdInPrefs(profile.getThemeHue()); - // restart activity to reflect theme change - finish(); - // un-hook all observed LiveData Data.profile.removeObservers(this); Data.profiles.removeObservers(this); Data.lastUpdateDate.removeObservers(this); - Intent intent = new Intent(this, this.getClass()); - intent.putExtra(BUNDLE_SAVED_STATE, bundle); - startActivity(intent); + + recreate(); } private void storeThemeIdInPrefs(int themeId) { // store the new theme id in the preferences -- 2.39.2