Created
June 14, 2022 09:16
-
-
Save mazzouzi/ad0b3e39101423a5f241db9bccaa6e55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DialogUtilLeak private constructor(private val context: Context?) { | |
fun showError(title: String?, message: String?) { | |
if (context == null || (context as Activity).isFinishing) { | |
return | |
} | |
MaterialAlertDialogBuilder(context) | |
.setCancelable(true) | |
.setTitle(title) | |
.setMessage(message) | |
.setPositiveButton("OK", null) | |
.create() | |
.show() | |
} | |
// fun showSuccess()... | |
// fun showLoader()... | |
companion object { | |
private var instance : DialogUtilLeak? = null | |
fun getInstance(context: Context): DialogUtilLeak { | |
if (instance == null) // NOT thread safe! | |
instance = DialogUtilLeak(context) | |
return instance!! | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment