From: Damyan Ivanov Date: Mon, 19 Apr 2021 20:07:17 +0000 (+0300) Subject: when deleting the currently active profile, switch to the first profile X-Git-Tag: v0.18.0~73 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=c8bd976d1d7f03e20db21c3056ac33c095c0057e;p=mobile-ledger.git when deleting the currently active profile, switch to the first profile --- 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 945e81c5..7df18278 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 @@ -383,6 +383,12 @@ public class MainActivity extends ProfileThemedActivity implements FabManager.Fa mProfileListAdapter.setProfileList(newList); createShortcuts(newList); + + Profile currentProfile = Data.getProfile(); + if (currentProfile == null || !newList.contains(currentProfile)) { + Logger.debug(TAG, "Switching profile because the current is no longer available"); + Data.setCurrentProfile(newList.get(0)); + } } /** * called when the current profile has changed