Skip to content

Commit

Permalink
Merge pull request #8727 from wmontwe/fix-tailrec-warning
Browse files Browse the repository at this point in the history
Remove tailrec as this is not a tailrec function
  • Loading branch information
wmontwe authored Jan 10, 2025
2 parents 0fb3663 + a952b73 commit 32a9866
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import android.app.Activity
import android.content.Context
import android.content.ContextWrapper

// Source: https://stackoverflow.com/a/58249983
tailrec fun Context.findActivity(): Activity? = this as? Activity
?: (this as? ContextWrapper)?.baseContext?.findActivity()
tailrec fun Context.findActivity(): Activity? {
return if (this is Activity) {
this
} else {
(this as? ContextWrapper)?.baseContext?.findActivity()
}
}

0 comments on commit 32a9866

Please sign in to comment.