Added IBankingClientCreator to get fints4javaBankingClient off MainWindowPresenter
This commit is contained in:
parent
6579dcfe3a
commit
a9883ff355
|
@ -17,4 +17,7 @@ dependencies {
|
|||
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
|
||||
|
||||
api "net.dankito.utils:java-utils:$javaUtilsVersion"
|
||||
|
||||
// TODO: try to get rid of this import
|
||||
api project(':fints4javaLib')
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package net.dankito.banking.ui
|
||||
|
||||
import net.dankito.banking.util.IBase64Service
|
||||
import net.dankito.fints.model.BankInfo
|
||||
import net.dankito.utils.IThreadPool
|
||||
import net.dankito.utils.web.client.IWebClient
|
||||
|
||||
|
||||
interface IBankingClientCreator {
|
||||
|
||||
fun createClient(bankInfo: BankInfo, // TODO: create own value object to get rid off fints4java dependency
|
||||
customerId: String,
|
||||
pin: String,
|
||||
webClient: IWebClient, // TODO: wrap away JavaUtils IWebClient
|
||||
base64Service: IBase64Service,
|
||||
threadPool: IThreadPool, // TODO: wrap away JavaUtils IThreadPool
|
||||
callback: BankingClientCallback
|
||||
): IBankingClient
|
||||
|
||||
}
|
|
@ -48,10 +48,9 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':fints4javaBankingClient')
|
||||
api project(':BankingUiCommon')
|
||||
|
||||
// TODO: try to get rid of this import
|
||||
implementation project(':fints4javaLib')
|
||||
implementation project(':fints4javaBankingClient')
|
||||
|
||||
implementation "com.github.clans:fab:$clansFloatingActionButtonVersion"
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.dankito.banking.fints4java.android.ui.dialogs.AddAccountDialog
|
|||
import net.dankito.banking.fints4java.android.ui.dialogs.EnterAtcDialog
|
||||
import net.dankito.banking.fints4java.android.ui.dialogs.EnterTanDialog
|
||||
import net.dankito.banking.fints4java.android.ui.views.MainActivityFloatingActionMenuButton
|
||||
import net.dankito.banking.fints4javaBankingClientCreator
|
||||
import net.dankito.banking.ui.BankingClientCallback
|
||||
import net.dankito.banking.ui.model.Account
|
||||
import net.dankito.banking.ui.model.tan.EnterTanGeneratorAtcResult
|
||||
|
@ -31,7 +32,7 @@ class MainActivity : AppCompatActivity() {
|
|||
private lateinit var floatingActionMenuButton: MainActivityFloatingActionMenuButton
|
||||
|
||||
|
||||
val presenter = MainWindowPresenter(Base64ServiceAndroid(), object : BankingClientCallback {
|
||||
val presenter = MainWindowPresenter(fints4javaBankingClientCreator(), Base64ServiceAndroid(), object : BankingClientCallback {
|
||||
|
||||
override fun enterTan(account: Account, tanChallenge: TanChallenge): EnterTanResult {
|
||||
return getTanFromUserOffUiThread(account, tanChallenge)
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.dankito.banking.fints4java.android.ui
|
|||
|
||||
import net.dankito.banking.ui.BankingClientCallback
|
||||
import net.dankito.banking.ui.IBankingClient
|
||||
import net.dankito.banking.ui.IBankingClientCreator
|
||||
import net.dankito.banking.ui.model.Account
|
||||
import net.dankito.banking.ui.model.AccountTransaction
|
||||
import net.dankito.banking.ui.model.BankAccount
|
||||
|
@ -10,7 +11,6 @@ import net.dankito.banking.ui.model.responses.AddAccountResponse
|
|||
import net.dankito.banking.ui.model.responses.BankingClientResponse
|
||||
import net.dankito.banking.ui.model.responses.GetTransactionsResponse
|
||||
import net.dankito.banking.util.IBase64Service
|
||||
import net.dankito.banking.util.UiCommonBase64ServiceWrapper
|
||||
import net.dankito.fints.banks.BankFinder
|
||||
import net.dankito.fints.model.BankInfo
|
||||
import net.dankito.utils.IThreadPool
|
||||
|
@ -21,7 +21,9 @@ import java.util.*
|
|||
import kotlin.collections.ArrayList
|
||||
|
||||
|
||||
open class MainWindowPresenter(protected val base64Service: IBase64Service,
|
||||
open class MainWindowPresenter(
|
||||
protected val bankingClientCreator: IBankingClientCreator,
|
||||
protected val base64Service: IBase64Service,
|
||||
protected val callback: BankingClientCallback
|
||||
) {
|
||||
|
||||
|
@ -45,7 +47,7 @@ open class MainWindowPresenter(protected val base64Service: IBase64Service,
|
|||
// TODO: move BankInfo out of fints4javaLib
|
||||
open fun addAccountAsync(bankInfo: BankInfo, customerId: String, pin: String, callback: (AddAccountResponse) -> Unit) {
|
||||
|
||||
val newClient = net.dankito.banking.fints4javaBankingClient(bankInfo, customerId, pin, OkHttpWebClient(), UiCommonBase64ServiceWrapper(base64Service), threadPool, this.callback)
|
||||
val newClient = bankingClientCreator.createClient(bankInfo, customerId, pin, OkHttpWebClient(), base64Service, threadPool, this.callback)
|
||||
|
||||
newClient.addAccountAsync { response ->
|
||||
val account = response.account
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
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.util.UiCommonBase64ServiceWrapper
|
||||
import net.dankito.fints.model.BankInfo
|
||||
import net.dankito.utils.IThreadPool
|
||||
import net.dankito.utils.web.client.IWebClient
|
||||
import net.dankito.utils.web.client.OkHttpWebClient
|
||||
|
||||
|
||||
open class fints4javaBankingClientCreator : IBankingClientCreator {
|
||||
|
||||
override fun createClient(bankInfo: BankInfo, customerId: String, pin: String, webClient: IWebClient,
|
||||
base64Service: IBase64Service, threadPool: IThreadPool, callback: BankingClientCallback): IBankingClient {
|
||||
|
||||
return fints4javaBankingClient(bankInfo, customerId, pin, OkHttpWebClient(), UiCommonBase64ServiceWrapper(base64Service), threadPool, callback)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue