48 lines
1.1 KiB
Kotlin
48 lines
1.1 KiB
Kotlin
package com.sw.inbound.dialog
|
|
|
|
object DialogManager {
|
|
|
|
private var dialogList: MutableList<BaseDialog> = mutableListOf()
|
|
|
|
fun addDialog(dialog: BaseDialog) {
|
|
if (dialogList.contains(dialog).not()) {
|
|
val className = dialog.javaClass.simpleName
|
|
val item = dialogList.firstOrNull { it.javaClass.simpleName == className }
|
|
item?.dismiss()
|
|
dialogList.add(dialog)
|
|
}
|
|
}
|
|
|
|
fun removeDialog(dialog: BaseDialog) {
|
|
dialogList.remove(dialog)
|
|
}
|
|
|
|
fun getDialogList(): MutableList<BaseDialog> {
|
|
return dialogList
|
|
}
|
|
|
|
fun dismissAll() {
|
|
dialogList.forEach {
|
|
it.dismiss()
|
|
}
|
|
}
|
|
|
|
fun dismissAllExcept(dialog: BaseDialog) {
|
|
dialogList.forEach {
|
|
if (it != dialog) {
|
|
it.dismiss()
|
|
}
|
|
}
|
|
}
|
|
|
|
fun contains(vararg className: String): Boolean {
|
|
val item = dialogList.firstOrNull { className.contains(it.javaClass.simpleName) }
|
|
return item != null
|
|
}
|
|
|
|
fun hasShowDialog(): Boolean {
|
|
val item = dialogList.firstOrNull { it.isShowing }
|
|
return item != null
|
|
}
|
|
|
|
} |