From d1b320307efeb1218c37d623b3f46865a4eaa297 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 29 Apr 2020 22:06:14 +0200 Subject: [PATCH] Fixed tracking selected account type --- .../banking/ui/model/SelectedAccountType.kt | 12 ++++++++++++ .../banking/ui/presenter/BankingPresenter.kt | 17 +++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 BankingUiCommon/src/main/java/net/dankito/banking/ui/model/SelectedAccountType.kt diff --git a/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/SelectedAccountType.kt b/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/SelectedAccountType.kt new file mode 100644 index 00000000..4151a3af --- /dev/null +++ b/BankingUiCommon/src/main/java/net/dankito/banking/ui/model/SelectedAccountType.kt @@ -0,0 +1,12 @@ +package net.dankito.banking.ui.model + + +enum class SelectedAccountType { + + AllAccounts, + + SingleAccount, + + SingleBankAccount + +} \ No newline at end of file diff --git a/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt b/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt index 85c9b3e9..55fd562f 100644 --- a/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -8,6 +8,7 @@ import net.dankito.banking.ui.IRouter import net.dankito.banking.ui.model.Account import net.dankito.banking.ui.model.AccountTransaction import net.dankito.banking.ui.model.BankAccount +import net.dankito.banking.ui.model.SelectedAccountType import net.dankito.banking.ui.model.parameters.TransferMoneyData import net.dankito.banking.ui.model.responses.AddAccountResponse import net.dankito.banking.ui.model.responses.BankingClientResponse @@ -54,7 +55,7 @@ open class BankingPresenter( protected var selectedBankAccountsField = mutableListOf() - protected var userSelectedSingleAccount = false + protected var selectedAccountType = SelectedAccountType.AllAccounts protected var saveAccountOnNextEnterTanInvocation = false @@ -384,30 +385,34 @@ open class BankingPresenter( open val balanceOfSelectedBankAccounts: BigDecimal get() = sumBalance(selectedBankAccounts.map { it.balance }) + + open val areAllAccountSelected: Boolean + get() = selectedAccountType == SelectedAccountType.AllAccounts + open fun isSingleSelectedAccount(account: Account): Boolean { - return userSelectedSingleAccount + return selectedAccountType == SelectedAccountType.SingleAccount && selectedBankAccountsField.map { it.account }.toSet().containsExactly(account) } open fun isSingleSelectedBankAccount(bankAccount: BankAccount): Boolean { - return userSelectedSingleAccount == false + return selectedAccountType == SelectedAccountType.SingleBankAccount && selectedBankAccountsField.containsExactly(bankAccount) } open fun selectedAllBankAccounts() { - userSelectedSingleAccount = false + selectedAccountType = SelectedAccountType.AllAccounts setSelectedBankAccounts(bankAccounts) } open fun selectedAccount(account: Account) { - userSelectedSingleAccount = true + selectedAccountType = SelectedAccountType.SingleAccount setSelectedBankAccounts(account.bankAccounts) } open fun selectedBankAccount(bankAccount: BankAccount) { - userSelectedSingleAccount = false + selectedAccountType = SelectedAccountType.SingleBankAccount setSelectedBankAccounts(listOf(bankAccount)) }