Fixed using of IAsyncRunner instead of IThreadPool

This commit is contained in:
dankito 2020-07-10 14:03:08 +02:00
parent f4312c52db
commit b05d927356
4 changed files with 16 additions and 19 deletions

View File

@ -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())
}
}

View File

@ -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 {

View File

@ -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))
}
}

View File

@ -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)
}
}