]> git.ktnx.net Git - mobile-ledger.git/commitdiff
new-transaction: avoid auto-completion pop-ups when applying data
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 28 Feb 2021 17:32:34 +0000 (19:32 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 1 Mar 2021 06:00:42 +0000 (06:00 +0000)
the data comes from the model, i.e. either from an applied template or
loading of a previous transaction (auto-completion of transaction
description)

app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java
app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java

index 4274a99b2620f4d825616a4c4604061a8330fef9..1725f91a64ae0c58ffc7ca5652db67007a7d1e3f 100644 (file)
@@ -26,6 +26,7 @@ import android.view.Gravity;
 import android.view.View;
 import android.view.inputmethod.EditorInfo;
 import android.widget.EditText;
+import android.widget.SimpleCursorAdapter;
 import android.widget.TextView;
 
 import androidx.annotation.ColorInt;
@@ -563,7 +564,17 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
                 if (item instanceof NewTransactionModel.TransactionHead) {
                     NewTransactionModel.TransactionHead head = item.toTransactionHead();
                     b.newTransactionDate.setText(head.getFormattedDate());
-                    b.newTransactionDescription.setText(head.getDescription());
+
+                    // avoid triggering completion pop-up
+                    SimpleCursorAdapter a =
+                            (SimpleCursorAdapter) b.newTransactionDescription.getAdapter();
+                    try {
+                        b.newTransactionDescription.setAdapter(null);
+                        b.newTransactionDescription.setText(head.getDescription());
+                    }
+                    finally {
+                        b.newTransactionDescription.setAdapter(a);
+                    }
 
                     b.transactionComment.setText(head.getComment());
                     //styleComment(b.transactionComment, head.getComment());
@@ -576,7 +587,16 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
                 else if (item instanceof NewTransactionModel.TransactionAccount) {
                     NewTransactionModel.TransactionAccount acc = item.toTransactionAccount();
 
-                    b.accountRowAccName.setText(acc.getAccountName());
+                    // avoid triggering completion pop-up
+                    AccountAutocompleteAdapter a =
+                            (AccountAutocompleteAdapter) b.accountRowAccName.getAdapter();
+                    try {
+                        b.accountRowAccName.setAdapter(null);
+                        b.accountRowAccName.setText(acc.getAccountName());
+                    }
+                    finally {
+                        b.accountRowAccName.setAdapter(a);
+                    }
 
                     final String amountHint = acc.getAmountHint();
                     if (amountHint == null) {
index 2e9027154ae805014d6e878336434faaa8c6a7e0..23be3eaf0a4734495c132f8a394aaf9538d8add4 100644 (file)
@@ -451,6 +451,8 @@ public class NewTransactionModel extends ViewModel {
             else
                 item.resetAmount();
         }
+        if (BuildConfig.DEBUG)
+            dumpItemList("Loaded previous transaction", newList);
 
         if (singleNegativeIndex != -1) {
             firstNegative.resetAmount();