I have 2 alerts in sequence, where the last one does not close with dismiss, could you help me please? Below my code snippet. I have a custom view
fun MaterialDialog.Builder.alertChangedIcon (action: () -> Unit) {
this.apply {
customView(R.layout.change_icon_dialog, false)
canceledOnTouchOutside(false)
build().run {
val btnPosition = this.findViewById(R.id.yesBtnView) as Button
btnPosition.setOnClickListener {
this.dismiss()
action.invoke()
}
}
show()
}
}
fun MaterialDialog.Builder.alertIconInfoChanged(action: () -> Unit) {
this.apply {
customView(R.layout.title_subtitle_two_buttons_dialog_prime,false)
canceledOnTouchOutside(false)
build().run {
val title = this.findViewById(R.id.alertTitleView) as TextView
val subtitle = this.findViewById(R.id.alertSubtitleView) as TextView
val positiveButton = this.findViewById(R.id.yesBtnView) as Button
val negativeButton = this.findViewById(R.id.noBtnView) as Button
title.text = context.getString(R.string.happy_birthday)
subtitle.text = context.getString(R.string.message_change_icon)
negativeButton.let {
it.text = context.getString(R.string.ok)
it.setOnClickListener {
this.dismiss()
action.invoke()
}
}
positiveButton.gone(false)
}
show()
}
}
And use as follows in my view:
override fun showAlertChangedIcon(action: () -> Unit) {
MaterialDialog.Builder(rootView.context).alertIconInfoChanged {
MaterialDialog.Builder(rootView.context).alertChangedIcon {
action.invoke()
}
}
}
And in my controller I have the functions that direct screens
.subscribe({ response ->
when (response) {
is Result.Success -> {
viewContract.showAlertChangedIcon {
when {
...
}
else -> {
...
}
}
}