From b05d92735661ce3f531ded0dfec34189d50e3f6c Mon Sep 17 00:00:00 2001 From: dankito Date: Fri, 10 Jul 2020 14:03:08 +0200 Subject: [PATCH] Fixed using of IAsyncRunner instead of IThreadPool --- .../dankito/banking/ui/android/di/BankingModule.kt | 11 +++++------ .../dankito/banking/fints4kBankingClientCreator.kt | 6 ++---- .../net/dankito/banking/hbci4jBankingClient.kt | 12 ++++++------ .../dankito/banking/hbci4jBankingClientCreator.kt | 6 +++--- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt index 1852edde..ef6fbb5f 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt @@ -25,7 +25,6 @@ import net.dankito.text.extraction.info.invoice.IInvoiceDataExtractor import net.dankito.text.extraction.info.invoice.InvoiceDataExtractor import net.dankito.text.extraction.pdf.PdfBoxAndroidPdfTextExtractor import net.dankito.text.extraction.pdf.iText2PdfTextExtractor -import net.dankito.utils.IThreadPool import net.dankito.utils.ThreadPool import net.dankito.utils.web.client.IWebClient import net.dankito.utils.web.client.OkHttpWebClient @@ -92,9 +91,9 @@ class BankingModule(private val applicationContext: Context) { @Named(DataFolderKey) dataFolder: File, persister: IBankingPersistence, remitteeSearcher: IRemitteeSearcher, bankIconFinder: IBankIconFinder, textExtractorRegistry: ITextExtractorRegistry, router: IRouter, invoiceDataExtractor: IInvoiceDataExtractor, - serializer: ISerializer, threadPool: IThreadPool) : BankingPresenter { + serializer: ISerializer, asyncRunner: IAsyncRunner) : BankingPresenter { return BankingPresenter(bankingClientCreator, bankFinder, dataFolder, persister, - remitteeSearcher, bankIconFinder, textExtractorRegistry, router, invoiceDataExtractor, serializer, threadPool) + remitteeSearcher, bankIconFinder, textExtractorRegistry, router, invoiceDataExtractor, serializer, asyncRunner) } @Provides @@ -170,14 +169,14 @@ class BankingModule(private val applicationContext: Context) { @Provides @Singleton - fun provideBase64Service() : net.dankito.banking.util.IBase64Service { + fun provideBase64Service() : IBase64Service { return Base64ServiceAndroid() } @Provides @Singleton - fun provideThreadPool() : IThreadPool { - return ThreadPool() + fun provideAsyncRunner() : IAsyncRunner { + return ThreadPoolAsyncRunner(ThreadPool()) } } \ No newline at end of file diff --git a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClientCreator.kt b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClientCreator.kt index 94cee084..af43a92f 100644 --- a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClientCreator.kt +++ b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClientCreator.kt @@ -3,10 +3,8 @@ package net.dankito.banking import net.dankito.banking.ui.BankingClientCallback import net.dankito.banking.ui.IBankingClient import net.dankito.banking.ui.IBankingClientCreator -import net.dankito.banking.util.IBase64Service import net.dankito.banking.bankfinder.BankInfo -import net.dankito.utils.IThreadPool -import net.dankito.utils.web.client.IWebClient +import net.dankito.banking.util.IAsyncRunner import java.io.File @@ -17,7 +15,7 @@ open class fints4kBankingClientCreator : IBankingClientCreator { customerId: String, pin: String, dataFolder: File, - threadPool: IThreadPool, + asyncRunner: IAsyncRunner, callback: BankingClientCallback ): IBankingClient { diff --git a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt index f1620c37..b7780315 100644 --- a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt +++ b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt @@ -13,7 +13,7 @@ import net.dankito.banking.ui.model.responses.GetTransactionsResponse import net.dankito.banking.util.AccountTransactionMapper import net.dankito.banking.util.hbci4jModelMapper import net.dankito.banking.bankfinder.BankInfo -import net.dankito.utils.IThreadPool +import net.dankito.banking.util.* import net.dankito.utils.ThreadPool import org.kapott.hbci.GV.HBCIJob import org.kapott.hbci.GV_Result.GVRKUms @@ -37,7 +37,7 @@ open class hbci4jBankingClient( customerId: String, pin: String, protected val dataFolder: File, - protected val threadPool: IThreadPool = ThreadPool(), + protected val asyncRunner: IAsyncRunner = ThreadPoolAsyncRunner(ThreadPool()), protected val callback: BankingClientCallback ) : IBankingClient { @@ -66,7 +66,7 @@ open class hbci4jBankingClient( override fun addAccountAsync(callback: (AddAccountResponse) -> Unit) { - threadPool.runAsync { + asyncRunner.runAsync { callback(addAccount()) } } @@ -124,7 +124,7 @@ open class hbci4jBankingClient( * or not. */ open fun getTransactionsOfLast90DaysAsync(bankAccount: BankAccount, callback: (GetTransactionsResponse) -> Unit) { - threadPool.runAsync { + asyncRunner.runAsync { callback(getTransactionsOfLast90Days(bankAccount)) } } @@ -143,7 +143,7 @@ open class hbci4jBankingClient( } override fun getTransactionsAsync(bankAccount: BankAccount, parameter: GetTransactionsParameter, callback: (GetTransactionsResponse) -> Unit) { - threadPool.runAsync { + asyncRunner.runAsync { callback(getTransactions(bankAccount, parameter)) } } @@ -233,7 +233,7 @@ open class hbci4jBankingClient( override fun transferMoneyAsync(data: TransferMoneyData, bankAccount: BankAccount, callback: (BankingClientResponse) -> Unit) { - threadPool.runAsync { + asyncRunner.runAsync { callback(transferMoney(data, bankAccount)) } } diff --git a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClientCreator.kt b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClientCreator.kt index e977f932..79c95d59 100644 --- a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClientCreator.kt +++ b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClientCreator.kt @@ -4,7 +4,7 @@ import net.dankito.banking.ui.BankingClientCallback import net.dankito.banking.ui.IBankingClient import net.dankito.banking.ui.IBankingClientCreator import net.dankito.banking.bankfinder.BankInfo -import net.dankito.utils.IThreadPool +import net.dankito.banking.util.IAsyncRunner import java.io.File @@ -15,11 +15,11 @@ open class hbci4jBankingClientCreator : IBankingClientCreator { customerId: String, pin: String, dataFolder: File, - threadPool: IThreadPool, + asyncRunner: IAsyncRunner, callback: BankingClientCallback ): IBankingClient { - return hbci4jBankingClient(bankInfo, customerId, pin, dataFolder, threadPool, callback) + return hbci4jBankingClient(bankInfo, customerId, pin, dataFolder, asyncRunner, callback) } } \ No newline at end of file