Skip to content

Instantly share code, notes, and snippets.

@mazzouzi
Last active June 16, 2022 12:03
Show Gist options
  • Save mazzouzi/c4aa904cc9f7edac8a63d65dad448227 to your computer and use it in GitHub Desktop.
Save mazzouzi/c4aa904cc9f7edac8a63d65dad448227 to your computer and use it in GitHub Desktop.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
_binding = ActivitySingletonLeakBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.button.setOnClickListener {
coroutineScope.launch(Dispatchers.IO) {
delay(500) // simulate API call
withContext(Dispatchers.Main) {
onError("An error occured")
}
}
}
}
private fun onError(errorMessage: String) {
DialogUtilLeak.getInstance(this).showError("News", errorMessage)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment