Skip to content

Instantly share code, notes, and snippets.

@mazzouzi
Created June 14, 2022 09:16
Show Gist options
  • Save mazzouzi/ad0b3e39101423a5f241db9bccaa6e55 to your computer and use it in GitHub Desktop.
Save mazzouzi/ad0b3e39101423a5f241db9bccaa6e55 to your computer and use it in GitHub Desktop.
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