Implemented closing Autocomplete popup on back button press
This commit is contained in:
parent
a56240a300
commit
fc94b47fca
|
@ -20,6 +20,7 @@ import kotlinx.android.synthetic.main.dialog_add_account.view.*
|
|||
import net.dankito.banking.fints4java.android.R
|
||||
import net.dankito.banking.fints4java.android.di.BankingComponent
|
||||
import net.dankito.banking.fints4java.android.ui.adapter.presenter.BankInfoPresenter
|
||||
import net.dankito.banking.fints4java.android.ui.extensions.closePopupOnBackButtonPress
|
||||
import net.dankito.banking.fints4java.android.util.StandardAutocompleteCallback
|
||||
import net.dankito.banking.ui.model.responses.AddAccountResponse
|
||||
import net.dankito.banking.ui.presenter.BankingPresenter
|
||||
|
@ -87,6 +88,7 @@ open class AddAccountDialog : DialogFragment() {
|
|||
.with(autocompleteCallback)
|
||||
.with(BankInfoPresenter(presenter, rootView.context))
|
||||
.build()
|
||||
.closePopupOnBackButtonPress(dialog)
|
||||
}
|
||||
|
||||
protected open fun addAccount() {
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.dankito.banking.fints4java.android.di.BankingComponent
|
|||
import net.dankito.banking.fints4java.android.ui.adapter.BankAccountsAdapter
|
||||
import net.dankito.banking.fints4java.android.ui.adapter.presenter.RemitteePresenter
|
||||
import net.dankito.banking.fints4java.android.ui.extensions.addEnterPressedListener
|
||||
import net.dankito.banking.fints4java.android.ui.extensions.closePopupOnBackButtonPress
|
||||
import net.dankito.banking.fints4java.android.ui.listener.ListItemSelectedListener
|
||||
import net.dankito.banking.fints4java.android.util.StandardAutocompleteCallback
|
||||
import net.dankito.banking.fints4java.android.util.StandardTextWatcher
|
||||
|
@ -182,6 +183,7 @@ open class TransferMoneyDialog : DialogFragment() {
|
|||
.with(autocompleteCallback)
|
||||
.with(RemitteePresenter(remitteeSearcher, edtxtRemitteeName.context))
|
||||
.build()
|
||||
.closePopupOnBackButtonPress(dialog)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package net.dankito.banking.fints4java.android.ui.extensions
|
||||
|
||||
import android.app.Dialog
|
||||
import android.view.KeyEvent
|
||||
import com.otaliastudios.autocomplete.Autocomplete
|
||||
|
||||
|
||||
/**
|
||||
* This will not work if Dialog is null!
|
||||
*
|
||||
* Making the Dialog parameter nullable is just for convienience to be able to call
|
||||
* Autocomplete
|
||||
* .on<>(view)
|
||||
* .build()
|
||||
* .closePopupOnBackButtonPress(dialog)
|
||||
*/
|
||||
fun Autocomplete<*>.closePopupOnBackButtonPress(dialog: Dialog?) {
|
||||
dialog?.setOnKeyListener { _, keyCode, _ ->
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (this.isPopupShowing) { // close autocomplete popup on back button press
|
||||
this.dismissPopup()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue