Fixed calling accountsChangedListeners on changes, e.g. when bank displayName or bank displayIndex changed

This commit is contained in:
dankito 2020-09-13 00:01:48 +02:00
parent f847e5e651
commit 6467964305
1 changed files with 15 additions and 1 deletions

View File

@ -393,16 +393,22 @@ open class BankingPresenter constructor(
open fun accountDisplayIndexUpdated(account: TypedCustomer) { open fun accountDisplayIndexUpdated(account: TypedCustomer) {
persistAccount(account) persistAccount(account)
callAccountsChangedListeners(account)
} }
open fun accountUpdated(bank: TypedCustomer) { open fun accountUpdated(bank: TypedCustomer) {
persistAccount(bank) persistAccount(bank)
callAccountsChangedListeners(bank)
getBankingClientForAccount(bank)?.dataChanged(bank) getBankingClientForAccount(bank)?.dataChanged(bank)
} }
open fun accountUpdated(account: TypedBankAccount) { open fun accountUpdated(account: TypedBankAccount) {
persistAccount(account.customer) persistAccount(account.customer)
callAccountsChangedListeners(account.customer as TypedCustomer)
} }
protected open fun persistAccount(customer: ICustomer<*, *>) { protected open fun persistAccount(customer: ICustomer<*, *>) {
@ -731,7 +737,15 @@ open class BankingPresenter constructor(
} }
protected open fun callAccountsChangedListeners() { protected open fun callAccountsChangedListeners() {
val accounts = this.customers val accounts = ArrayList(this.customers)
ArrayList(accountsChangedListeners).forEach {
it(accounts) // TODO: use RxJava for this
}
}
protected open fun callAccountsChangedListeners(account: TypedCustomer) {
val accounts = ArrayList(listOf(account))
ArrayList(accountsChangedListeners).forEach { ArrayList(accountsChangedListeners).forEach {
it(accounts) // TODO: use RxJava for this it(accounts) // TODO: use RxJava for this