]> git.ktnx.net Git - mobile-ledger.git/commitdiff
Data: single central method for changing the current profile
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 10 Jan 2019 21:27:41 +0000 (21:27 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 10 Jan 2019 21:27:41 +0000 (21:27 +0000)
sets the option in the DB and Data.profile

app/src/main/java/net/ktnx/mobileledger/model/Data.java

index d8b3b19011dc636107e640d73fcfd1c372b88db5..7781f3285d5ab2bd4b8411bd6304838996d50b49 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.ktnx.mobileledger.model;
 
+import net.ktnx.mobileledger.utils.MLDB;
 import net.ktnx.mobileledger.utils.ObservableAtomicInteger;
 import net.ktnx.mobileledger.utils.ObservableList;
 import net.ktnx.mobileledger.utils.ObservableValue;
@@ -34,4 +35,8 @@ public final class Data {
     public static ObservableList<MobileLedgerProfile> profiles =
             new ObservableList<>(new ArrayList<>());
     public static ObservableValue<Boolean> optShowOnlyStarred = new ObservableValue<>();
+    public static void setCurrentProfile(MobileLedgerProfile newProfile) {
+        MLDB.set_option_value(MLDB.OPT_PROFILE_UUID, newProfile.getUuid());
+        profile.set(newProfile);
+    }
 }