]> git.ktnx.net Git - mobile-ledger-staging.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/model/Data.java
fixed a hard to reproduce crash upon returning to the app
[mobile-ledger-staging.git] / app / src / main / java / net / ktnx / mobileledger / model / Data.java
index 74e274d672d82e78d3d48b6b9975702294bc3283..f0f3987789e56673285923eee2209dc915d10b13 100644 (file)
@@ -32,9 +32,11 @@ import net.ktnx.mobileledger.utils.LockHolder;
 import net.ktnx.mobileledger.utils.Locker;
 import net.ktnx.mobileledger.utils.Logger;
 import net.ktnx.mobileledger.utils.MLDB;
+import net.ktnx.mobileledger.utils.ObservableValue;
 
 import java.text.NumberFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Locale;
 import java.util.Objects;
@@ -54,6 +56,13 @@ public final class Data {
     public static final MutableLiveData<Boolean> currencyGap = new MutableLiveData<>(true);
     public static final MutableLiveData<Locale> locale = new MutableLiveData<>();
     public static final MutableLiveData<Boolean> drawerOpen = new MutableLiveData<>(false);
+    public static final MutableLiveData<Date> lastUpdateDate = new MutableLiveData<>(null);
+    public static final MutableLiveData<Integer> lastUpdateTransactionCount =
+            new MutableLiveData<>(0);
+    public static final MutableLiveData<Integer> lastUpdateAccountCount = new MutableLiveData<>(0);
+    public static final ObservableValue<String> lastTransactionsUpdateText =
+            new ObservableValue<>();
+    public static final ObservableValue<String> lastAccountsUpdateText = new ObservableValue<>();
     private static final MutableLiveData<MobileLedgerProfile> profile =
             new InertMutableLiveData<>();
     private static final AtomicInteger backgroundTaskCount = new AtomicInteger(0);
@@ -85,6 +94,10 @@ public final class Data {
         MLDB.setOption(MLDB.OPT_PROFILE_UUID, newProfile.getUuid());
         profile.setValue(newProfile);
     }
+    public static void postCurrentProfile(@NonNull MobileLedgerProfile newProfile) {
+        MLDB.setOption(MLDB.OPT_PROFILE_UUID, newProfile.getUuid());
+        profile.postValue(newProfile);
+    }
     public static int getProfileIndex(MobileLedgerProfile profile) {
         try (LockHolder ignored = profilesLocker.lockForReading()) {
             List<MobileLedgerProfile> prList = profiles.getValue();
@@ -191,6 +204,7 @@ public final class Data {
         MobileLedgerProfile startupProfile = getProfile(profileUUID);
         if (startupProfile != null)
             setCurrentProfile(startupProfile);
+        Logger.debug("profile", "initProfile() returning " + startupProfile);
         return startupProfile;
     }