]> git.ktnx.net Git - mobile-ledger.git/commitdiff
avoid overlapping observations
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 17 Apr 2020 19:21:56 +0000 (22:21 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 17 Apr 2020 19:21:56 +0000 (22:21 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java

index 9f5cd8c49108e622e288da4d066ad35e8e510bb4..34d3a8493a3a9e782de7d315b1f25d9e6656d7bb 100644 (file)
@@ -72,9 +72,13 @@ public class NewTransactionModel extends ViewModel {
      */
     private final HashMap<String, List<Item>> slots = new HashMap<>();
     private int checkHoldCounter = 0;
-    private Observer<MobileLedgerProfile> profileObserver = profile ->showCurrency.postValue(profile.getShowCommodityByDefault());
+    private boolean observingDataProfile;
+    private Observer<MobileLedgerProfile> profileObserver =
+            profile -> showCurrency.postValue(profile.getShowCommodityByDefault());
     public void observeDataProfile(LifecycleOwner activity) {
-        Data.profile.observe(activity, profileObserver);
+        if (!observingDataProfile)
+            Data.profile.observe(activity, profileObserver);
+        observingDataProfile = true;
     }
     void holdSubmittableChecks() {
         checkHoldCounter++;