mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-16 07:10:29 +05:30
16 lines
496 B
Kotlin
16 lines
496 B
Kotlin
|
package com.github.libretube.helpers
|
||
|
|
||
|
import android.content.Context
|
||
|
import android.content.ContextWrapper
|
||
|
import com.github.libretube.ui.activities.MainActivity
|
||
|
|
||
|
object ContextHelper {
|
||
|
fun unwrapActivity(context: Context): MainActivity {
|
||
|
var correctContext: Context? = context
|
||
|
while (correctContext !is MainActivity && correctContext is ContextWrapper) {
|
||
|
correctContext = correctContext.baseContext
|
||
|
}
|
||
|
return correctContext as MainActivity
|
||
|
}
|
||
|
}
|