diff --git a/myExpenses/src/main/java/org/totschnig/myexpenses/activity/ExpenseEdit.kt b/myExpenses/src/main/java/org/totschnig/myexpenses/activity/ExpenseEdit.kt index 8eaeef4e78..16e8f2bab8 100755 --- a/myExpenses/src/main/java/org/totschnig/myexpenses/activity/ExpenseEdit.kt +++ b/myExpenses/src/main/java/org/totschnig/myexpenses/activity/ExpenseEdit.kt @@ -729,7 +729,7 @@ open class ExpenseEdit : AmountActivity(), ContribIFac abortWithMessage(getString(R.string.dialog_command_disabled_insert_transfer)) } else { if (::delegate.isInitialized) { - delegate.setAccounts(accounts) + delegate.setAccounts(accounts, !accountsLoaded) loadDebts() accountsLoaded = true if (mIsResumed) setupListeners() @@ -741,10 +741,13 @@ open class ExpenseEdit : AmountActivity(), ContribIFac lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { viewModel.accounts.collect { + val firstLoad = !accountsLoaded setAccounts(it) - collectSplitParts() - if (isSplitParent) { - viewModel.loadSplitParts(delegate.rowId, isTemplate) + if (firstLoad) { + collectSplitParts() + if (isSplitParent) { + viewModel.loadSplitParts(delegate.rowId, isTemplate) + } } } } diff --git a/myExpenses/src/main/java/org/totschnig/myexpenses/delegate/TransactionDelegate.kt b/myExpenses/src/main/java/org/totschnig/myexpenses/delegate/TransactionDelegate.kt index a885478115..00049bf296 100644 --- a/myExpenses/src/main/java/org/totschnig/myexpenses/delegate/TransactionDelegate.kt +++ b/myExpenses/src/main/java/org/totschnig/myexpenses/delegate/TransactionDelegate.kt @@ -993,18 +993,19 @@ abstract class TransactionDelegate( updateAccount(mAccounts[selected]) } - open fun setAccounts(data: List) { + open fun setAccounts(data: List, firstLoad: Boolean) { mAccounts.clear() mAccounts.addAll(data) accountSpinner.adapter = IdAdapter(context, data).apply { setDropDownViewResource(androidx.appcompat.R.layout.support_simple_spinner_dropdown_item) } - - viewBinding.Amount.setTypeEnabled(true) - isProcessingLinkedAmountInputs = true - configureType() - isProcessingLinkedAmountInputs = false - setAccount() + if (firstLoad) { + viewBinding.Amount.setTypeEnabled(true) + isProcessingLinkedAmountInputs = true + configureType() + isProcessingLinkedAmountInputs = false + setAccount() + } } private fun configureStatusSpinner() {