From: Damyan Ivanov Date: Fri, 17 Apr 2020 19:21:56 +0000 (+0300) Subject: avoid overlapping observations X-Git-Tag: v0.12.0~50 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=73db4eac40acaf517513c6ccc0c3e44472c7dbdf;p=mobile-ledger.git avoid overlapping observations --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java index 9f5cd8c4..34d3a849 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java @@ -72,9 +72,13 @@ public class NewTransactionModel extends ViewModel { */ private final HashMap> slots = new HashMap<>(); private int checkHoldCounter = 0; - private Observer profileObserver = profile ->showCurrency.postValue(profile.getShowCommodityByDefault()); + private boolean observingDataProfile; + private Observer 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++;