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