]> git.ktnx.net Git - mobile-ledger.git/commitdiff
NewTransItem/amountHint: allow for null hints, and avoid extra Live triggers
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 13 Nov 2019 21:39:46 +0000 (23:39 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 13 Nov 2019 21:39:46 +0000 (23:39 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java

index 914a478b14945bce6c6f49f5ce7e8c930d8f9172..66031354141a0aaee54ab08feef8d2e599806f48 100644 (file)
@@ -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,