From 80d43ee6b1f34f923dd78ea33847d4addf990fde Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 28 Feb 2021 19:32:34 +0200 Subject: [PATCH] new-transaction: avoid auto-completion pop-ups when applying data the data comes from the model, i.e. either from an applied template or loading of a previous transaction (auto-completion of transaction description) --- .../NewTransactionItemHolder.java | 24 +++++++++++++++++-- .../new_transaction/NewTransactionModel.java | 2 ++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java index 4274a99b..1725f91a 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java @@ -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) { diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java index 2e902715..23be3eaf 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java @@ -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(); -- 2.39.2