Skip to content

Instantly share code, notes, and snippets.

@paulocoutinhox
Created December 28, 2020 17:13
Show Gist options
  • Save paulocoutinhox/4d6dd66b983ab4a0bd63f0a11538ba23 to your computer and use it in GitHub Desktop.
Save paulocoutinhox/4d6dd66b983ab4a0bd63f0a11538ba23 to your computer and use it in GitHub Desktop.
/**
* Returns true when [Context] is unavailable or is about to become unavailable
*/
fun Context?.isDoomed(): Boolean = when (this) {
null -> true
is Application -> false
is Activity -> (this.isDestroyed or this.isFinishing)
else -> false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment