Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit a952b736 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé
Browse files

Fix tailrec as this was not a tailrec function

parent 04b95c66
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -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()
    }
}