Fixed that AccountsChangedListener may gets called off UI thread

This commit is contained in:
dankito 2020-04-29 00:54:53 +02:00
parent 977e5101e6
commit 071c0a1b8d
4 changed files with 11 additions and 6 deletions

View File

@ -16,8 +16,10 @@ open class MainMenuBar(protected val presenter: BankingPresenter) : View() {
init {
presenter.addAccountsChangedListener {
runLater {
checkIfThereAreAccountsThatCanTransferMoney()
}
}
checkIfThereAreAccountsThatCanTransferMoney()
}

View File

@ -99,7 +99,7 @@ open class AccountTransactionsControlView(
protected open fun initLogic() {
presenter.addAccountsChangedListener { accountsChanged() }
presenter.addAccountsChangedListener { runLater { accountsChanged() } }
presenter.addSelectedBankAccountsChangedListener { selectedBankAccountsChanged() }
checkIfSupportsTransferringMoneyOnUiThread()

View File

@ -3,11 +3,9 @@ package net.dankito.banking.ui.javafx.controls
import javafx.collections.FXCollections
import javafx.geometry.Pos
import javafx.scene.control.TreeItem
import javafx.scene.control.TreeView
import javafx.scene.layout.Priority
import net.dankito.banking.ui.javafx.model.AccountsAccountTreeItem
import net.dankito.banking.ui.javafx.model.AccountsBankAccountTreeItem
import net.dankito.banking.ui.javafx.model.AccountsRootTreeItem
import net.dankito.banking.ui.presenter.BankingPresenter
import net.dankito.utils.javafx.ui.controls.addButton
import net.dankito.utils.javafx.ui.extensions.fixedHeight
@ -22,9 +20,11 @@ open class AccountsView(protected val presenter: BankingPresenter) : View() {
init {
presenter.addAccountsChangedListener {
runLater {
accounts.setAll(it)
}
}
}
override val root = vbox {

View File

@ -5,6 +5,7 @@ import com.github.clans.fab.FloatingActionButton
import com.github.clans.fab.FloatingActionMenu
import kotlinx.android.synthetic.main.view_floating_action_button_main.view.*
import net.dankito.banking.ui.presenter.BankingPresenter
import net.dankito.utils.android.extensions.asActivity
open class MainActivityFloatingActionMenuButton(floatingActionMenu: FloatingActionMenu, protected val presenter: BankingPresenter)
@ -16,8 +17,10 @@ open class MainActivityFloatingActionMenuButton(floatingActionMenu: FloatingActi
setupButtons(floatingActionMenu)
presenter.addAccountsChangedListener {
fabTransferMoney.context.asActivity()?.runOnUiThread {
checkIfThereAreAccountsThatCanTransferMoney()
}
}
checkIfThereAreAccountsThatCanTransferMoney()
}