From cf5745a939dd043b6b144c416fd4e8257b2cac66 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 24 Apr 2021 16:17:10 +0000 Subject: [PATCH] avoid switching current profile when profiles are rearranged on rearrange the object instances change so the equality check needs to be done on IDs, not object instances --- .../ktnx/mobileledger/ui/activity/MainActivity.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 406d0d73..d9ac65b7 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 @@ -391,7 +391,16 @@ public class MainActivity extends ProfileThemedActivity implements FabManager.Fa createShortcuts(newList); Profile currentProfile = Data.getProfile(); - if (currentProfile == null || !newList.contains(currentProfile)) { + boolean currentProfilePresent = false; + if (currentProfile != null) { + for (Profile p : newList) { + if (p.getId() == currentProfile.getId()) { + currentProfilePresent = true; + break; + } + } + } + if (!currentProfilePresent) { Logger.debug(TAG, "Switching profile because the current is no longer available"); Data.setCurrentProfile(newList.get(0)); } -- 2.39.5