From 73db4eac40acaf517513c6ccc0c3e44472c7dbdf Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 17 Apr 2020 22:21:56 +0300 Subject: [PATCH] avoid overlapping observations --- .../mobileledger/ui/activity/NewTransactionModel.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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++; -- 2.39.5