Skip to content

Instantly share code, notes, and snippets.

@gahfy
Created June 24, 2018 13:17
Show Gist options
  • Save gahfy/2ab9514b52e1bc072adbaa0e84874238 to your computer and use it in GitHub Desktop.
Save gahfy/2ab9514b52e1bc072adbaa0e84874238 to your computer and use it in GitHub Desktop.
fun View.getParentActivity(): AppCompatActivity?{
var context = this.context
while (context is ContextWrapper) {
if (context is AppCompatActivity) {
return context
}
context = context.baseContext
}
return null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment