From c8bd976d1d7f03e20db21c3056ac33c095c0057e Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Mon, 19 Apr 2021 23:07:17 +0300 Subject: [PATCH] when deleting the currently active profile, switch to the first profile --- .../net/ktnx/mobileledger/ui/activity/MainActivity.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- 2.39.2