初始代码提交
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user