Little refactoring

This commit is contained in:
dankito 2020-09-09 16:40:36 +02:00
parent 29bfaa80ac
commit 69c30c2ebc
1 changed files with 13 additions and 11 deletions

View File

@ -69,30 +69,32 @@ open class AddAccountDialog : DialogFragment() {
} }
protected open fun setupUI(rootView: View) { protected open fun setupUI(rootView: View) {
initBankListAutocompletion(rootView) rootView.apply {
initBankListAutocompletion(edtxtBank)
rootView.edtxtCustomerId.addTextChangedListener(otherEditTextChangedWatcher) edtxtCustomerId.addTextChangedListener(otherEditTextChangedWatcher)
rootView.edtxtPin.addTextChangedListener(otherEditTextChangedWatcher) edtxtPin.addTextChangedListener(otherEditTextChangedWatcher)
addAccountIfEnterPressed(rootView.edtxtBank) addAccountIfEnterPressed(edtxtBank)
addAccountIfEnterPressed(rootView.edtxtCustomerId) addAccountIfEnterPressed(edtxtCustomerId)
addAccountIfEnterPressed(rootView.edtxtPin) addAccountIfEnterPressed(edtxtPin)
rootView.btnAddAccount.setOnClickListener { addAccount() } btnAddAccount.setOnClickListener { addAccount() }
rootView.btnCancel.setOnClickListener { dismiss() } btnCancel.setOnClickListener { dismiss() }
}
} }
private fun initBankListAutocompletion(rootView: View) { private fun initBankListAutocompletion(edtxtBank: EditText) {
val autocompleteCallback = StandardAutocompleteCallback<BankInfo> { _, item -> val autocompleteCallback = StandardAutocompleteCallback<BankInfo> { _, item ->
bankSelected(item) bankSelected(item)
true true
} }
Autocomplete.on<BankInfo>(rootView.edtxtBank) Autocomplete.on<BankInfo>(edtxtBank)
.with(6f) .with(6f)
.with(ColorDrawable(Color.WHITE)) .with(ColorDrawable(Color.WHITE))
.with(autocompleteCallback) .with(autocompleteCallback)
.with(BankInfoPresenter(presenter, rootView.context)) .with(BankInfoPresenter(presenter, edtxtBank.context))
.build() .build()
.closePopupOnBackButtonPress(dialog) .closePopupOnBackButtonPress(dialog)
} }