-
-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6611 from Bnyro/master
fix: hide go to video action when in no internet mode
- Loading branch information
Showing
6 changed files
with
25 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
app/src/main/java/com/github/libretube/helpers/ContextHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
package com.github.libretube.helpers | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.ContextWrapper | ||
import com.github.libretube.ui.activities.MainActivity | ||
|
||
object ContextHelper { | ||
fun unwrapActivity(context: Context): MainActivity { | ||
inline fun <reified T : Activity> tryUnwrapActivity(context: Context): T? { | ||
var correctContext: Context? = context | ||
while (correctContext !is MainActivity && correctContext is ContextWrapper) { | ||
while (correctContext !is T && correctContext is ContextWrapper) { | ||
correctContext = correctContext.baseContext | ||
} | ||
return correctContext as MainActivity | ||
return correctContext as? T | ||
} | ||
|
||
inline fun <reified T : Activity> unwrapActivity(context: Context): T = tryUnwrapActivity(context)!! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters