优化
This commit is contained in:
@@ -17,25 +17,33 @@ object Loading {
|
|||||||
private var dialog: LoadingDialog? = null
|
private var dialog: LoadingDialog? = null
|
||||||
|
|
||||||
fun show(activity: Activity) {
|
fun show(activity: Activity) {
|
||||||
if (activity.isFinishing || activity.isDestroyed) {
|
try {
|
||||||
return
|
if (activity.isFinishing || activity.isDestroyed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (dialog?.isShowing == true) {
|
||||||
|
dialog?.dismiss()
|
||||||
|
}
|
||||||
|
if (dialog == null) {
|
||||||
|
dialog = LoadingDialog(activity)
|
||||||
|
}
|
||||||
|
dialog?.show()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
if (dialog?.isShowing == true) {
|
|
||||||
dialog?.dismiss()
|
|
||||||
}
|
|
||||||
if (dialog == null) {
|
|
||||||
dialog = LoadingDialog(activity)
|
|
||||||
}
|
|
||||||
dialog?.show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dismiss() {
|
fun dismiss() {
|
||||||
dialog?.let {
|
try {
|
||||||
if (it.isShowing) {
|
dialog?.let {
|
||||||
it.dismiss()
|
if (it.isShowing) {
|
||||||
|
it.dismiss()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
dialog = null
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
dialog = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user