Implemented displaying selected account / bank account

This commit is contained in:
dankito 2020-04-22 20:45:11 +02:00
parent 0699eaf977
commit 21b90585e0
3 changed files with 24 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import net.dankito.fints.banks.BankFinder
import net.dankito.fints.model.BankInfo import net.dankito.fints.model.BankInfo
import net.dankito.utils.IThreadPool import net.dankito.utils.IThreadPool
import net.dankito.utils.ThreadPool import net.dankito.utils.ThreadPool
import net.dankito.utils.extensions.containsExactly
import net.dankito.utils.extensions.ofMaxLength import net.dankito.utils.extensions.ofMaxLength
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.io.File import java.io.File
@ -50,6 +51,8 @@ open class BankingPresenter(
protected var selectedBankAccountsField = mutableListOf<BankAccount>() protected var selectedBankAccountsField = mutableListOf<BankAccount>()
protected var userSelectedSingleAccount = false
protected var saveAccountOnNextEnterTanInvocation = false protected var saveAccountOnNextEnterTanInvocation = false
@ -138,6 +141,8 @@ open class BankingPresenter(
if (response.isSuccessful) { if (response.isSuccessful) {
addClientForAccount(account, newClient) addClientForAccount(account, newClient)
selectedAccount(account)
callAccountsChangedListeners() callAccountsChangedListeners()
persistAccount(account) persistAccount(account)
@ -147,8 +152,6 @@ open class BankingPresenter(
retrievedAccountTransactions(bankAccount, response) retrievedAccountTransactions(bankAccount, response)
} }
} }
selectedAccount(account)
} }
callback(response) callback(response)
@ -315,15 +318,31 @@ open class BankingPresenter(
open val balanceOfSelectedBankAccounts: BigDecimal open val balanceOfSelectedBankAccounts: BigDecimal
get() = sumBalance(selectedBankAccounts.map { it.balance }) get() = sumBalance(selectedBankAccounts.map { it.balance })
open fun isSingleSelectedAccount(account: Account): Boolean {
return userSelectedSingleAccount
&& selectedBankAccountsField.map { it.account }.toSet().containsExactly(account)
}
open fun isSingleSelectedBankAccount(bankAccount: BankAccount): Boolean {
return userSelectedSingleAccount == false
&& selectedBankAccountsField.containsExactly(bankAccount)
}
open fun selectedAllBankAccounts() { open fun selectedAllBankAccounts() {
userSelectedSingleAccount = false
setSelectedBankAccounts(bankAccounts) setSelectedBankAccounts(bankAccounts)
} }
open fun selectedAccount(account: Account) { open fun selectedAccount(account: Account) {
userSelectedSingleAccount = true
setSelectedBankAccounts(account.bankAccounts) setSelectedBankAccounts(account.bankAccounts)
} }
open fun selectedBankAccount(bankAccount: BankAccount) { open fun selectedBankAccount(bankAccount: BankAccount) {
userSelectedSingleAccount = false
setSelectedBankAccounts(listOf(bankAccount)) setSelectedBankAccounts(listOf(bankAccount))
} }

View File

@ -6,7 +6,7 @@ ext {
kotlinVersion = '1.3.61' kotlinVersion = '1.3.61'
javaUtilsVersion = '1.0.9' javaUtilsVersion = '1.0.16-SNAPSHOT'
hbci4jVersion = '3.1.37' hbci4jVersion = '3.1.37'

View File

@ -117,6 +117,7 @@ open class DrawerView(
.withName(account.displayName) .withName(account.displayName)
.withLevel(AccountLevel) .withLevel(AccountLevel)
.withIcon(activity, FontAwesome.Icon.faw_piggy_bank, R.color.primaryTextColor_Dark) .withIcon(activity, FontAwesome.Icon.faw_piggy_bank, R.color.primaryTextColor_Dark)
.withSelected(presenter.isSingleSelectedAccount(account))
.withOnDrawerItemClickListener { _, _, _ -> itemClicked { presenter.selectedAccount(account) } } .withOnDrawerItemClickListener { _, _, _ -> itemClicked { presenter.selectedAccount(account) } }
} }
@ -125,6 +126,7 @@ open class DrawerView(
SecondaryDrawerItem() SecondaryDrawerItem()
.withName(bankAccount.displayName) .withName(bankAccount.displayName)
.withLevel(BankAccountLevel) .withLevel(BankAccountLevel)
.withSelected(presenter.isSingleSelectedBankAccount(bankAccount))
.withOnDrawerItemClickListener { _, _, _ -> itemClicked { presenter.selectedBankAccount(bankAccount) } } .withOnDrawerItemClickListener { _, _, _ -> itemClicked { presenter.selectedBankAccount(bankAccount) } }
} }
} }