From: Damyan Ivanov Date: Wed, 13 Nov 2019 21:39:46 +0000 (+0200) Subject: NewTransItem/amountHint: allow for null hints, and avoid extra Live triggers X-Git-Tag: v0.11.0~64 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=33196c9c9b597020be0dfa487be2a350d44ee541;p=mobile-ledger.git NewTransItem/amountHint: allow for null hints, and avoid extra Live triggers --- 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 914a478b..66031354 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 @@ -290,6 +290,17 @@ public class NewTransactionModel extends ViewModel { } public void setAmountHint(String amountHint) { ensureType(ItemType.transactionRow); + + // avoid unnecessary triggers + if (amountHint == null) { + if (this.amountHint.getValue() == null) + return; + } + else { + if (amountHint.equals(this.amountHint.getValue())) + return; + } + this.amountHint.setValue(amountHint); } public void observeAmountHint(@NonNull @NotNull androidx.lifecycle.LifecycleOwner owner,