improve dialog queue

This commit is contained in:
Phillip Thelen 2021-06-29 19:04:09 +02:00
parent 329ed7f212
commit e39c0bf643

View file

@ -301,10 +301,21 @@ open class HabiticaAlertDialog(context: Context) : AlertDialog(context, R.style.
}
private fun addToQueue(dialog: HabiticaAlertDialog) {
if (dialogQueue.isEmpty()) {
if (checkIfQueueAvailable()) {
dialog.show()
}
dialogQueue.add(dialog)
}
private fun checkIfQueueAvailable(): Boolean {
val currentDialog = dialogQueue.firstOrNull() ?: return true
if (currentDialog.isShowing) {
return false
} else {
// The Dialog was probably dismissed in a weird way. Clear it out so that the queue doesn't get stuck
dialogQueue.removeAt(0)
return true
}
}
}
}