From 33196c9c9b597020be0dfa487be2a350d44ee541 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Wed, 13 Nov 2019 23:39:46 +0200 Subject: [PATCH] NewTransItem/amountHint: allow for null hints, and avoid extra Live triggers --- .../mobileledger/ui/activity/NewTransactionModel.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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, -- 2.39.5