]> git.ktnx.net Git - mobile-ledger.git/commitdiff
avoid switching current profile when profiles are rearranged
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 24 Apr 2021 16:17:10 +0000 (16:17 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 25 Apr 2021 17:07:58 +0000 (17:07 +0000)
on rearrange the object instances change so the equality check needs to
be done on IDs, not object instances

app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java

index 406d0d7364da6f4c4c083529be6357dc72b0b9b4..d9ac65b71aa43ca3b08a42d8c2b17efdf9c7f065 100644 (file)
@@ -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));
         }