]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
profiles: ensure single instance per profile, fix havoc on add/removal of a profile
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / MainActivity.java
index 90f88685c5a3696ef090aa578a375f110318af0f..fbb99989ebd6de9b91c3528d3388ad5a15e51497 100644 (file)
@@ -170,10 +170,9 @@ public class MainActivity extends AppCompatActivity {
         });
     }
     private void setupProfile() {
-        Data.profiles.setList(MobileLedgerProfile.loadAllFromDB());
-        MobileLedgerProfile profile = null;
-
         String profileUUID = MLDB.getOption(MLDB.OPT_PROFILE_UUID, null);
+        MobileLedgerProfile profile;
+
         if (profileUUID == null) {
             if (Data.profiles.isEmpty()) {
                 Data.profiles.setList(MobileLedgerProfile.createInitialProfileList());
@@ -196,9 +195,10 @@ public class MainActivity extends AppCompatActivity {
                 editor.clear();
                 editor.apply();
             }
+            else profile = Data.profiles.get(0);
         }
         else {
-            profile = MobileLedgerProfile.loadUUIDFromDB(profileUUID);
+            profile = MobileLedgerProfile.loadAllFromDB(profileUUID);
         }
 
         if (profile == null) profile = Data.profiles.get(0);