Skip to content

Commit

Permalink
Move ContextExtensions´ to :core:android:common` module and changed…
Browse files Browse the repository at this point in the history
… it to satisfy tailrec
  • Loading branch information
wmontwe committed Aug 7, 2024
1 parent b1825c2 commit 8cf6d0e
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
@file:JvmName("ContextHelper")

package com.fsck.k9.ui.helper
package app.k9mail.core.android.common.activity

import android.app.Activity
import android.content.Context
import android.content.ContextWrapper

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

0 comments on commit 8cf6d0e

Please sign in to comment.