From: Damyan Ivanov Date: Sun, 28 Feb 2021 17:32:34 +0000 (+0200) Subject: new-transaction: avoid auto-completion pop-ups when applying data X-Git-Tag: v0.17.0~64 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=80d43ee6b1f34f923dd78ea33847d4addf990fde;p=mobile-ledger.git 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) --- 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();