mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
use activity instead of context
This commit is contained in:
parent
5b9ff65f7b
commit
8f65f99b29
3 changed files with 8 additions and 11 deletions
|
@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.ui.download
|
|||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
@ -33,7 +32,6 @@ import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
|
|||
import com.lagradost.cloudstream3.mvvm.observe
|
||||
import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick
|
||||
import com.lagradost.cloudstream3.ui.player.BasicLink
|
||||
import com.lagradost.cloudstream3.ui.player.DownloadedPlayerActivity
|
||||
import com.lagradost.cloudstream3.ui.player.GeneratorPlayer
|
||||
import com.lagradost.cloudstream3.ui.player.LinkGenerator
|
||||
import com.lagradost.cloudstream3.ui.player.OfflinePlaybackHelper.playUri
|
||||
|
@ -280,6 +278,6 @@ class DownloadFragment : Fragment() {
|
|||
) { result ->
|
||||
if (result.resultCode != Activity.RESULT_OK) return@registerForActivityResult
|
||||
val selectedVideoUri = result?.data?.data ?: return@registerForActivityResult
|
||||
playUri(context ?: return@registerForActivityResult, selectedVideoUri)
|
||||
playUri(activity ?: return@registerForActivityResult, selectedVideoUri)
|
||||
}
|
||||
}
|
|
@ -54,11 +54,11 @@ class DownloadedPlayerActivity : AppCompatActivity() {
|
|||
if (item?.uri != null)
|
||||
playUri(this, item.uri)
|
||||
else if (url != null)
|
||||
playLink(url)
|
||||
playLink(this, url)
|
||||
else if (data != null)
|
||||
playUri(this, data)
|
||||
else if (extraText != null)
|
||||
playLink(extraText)
|
||||
playLink(this, extraText)
|
||||
else {
|
||||
finish()
|
||||
return
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package com.lagradost.cloudstream3.ui.player
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ContentUris
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import androidx.core.content.ContextCompat.getString
|
||||
import com.lagradost.cloudstream3.CommonActivity.activity
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.utils.ExtractorUri
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||
import com.lagradost.safefile.SafeFile
|
||||
|
||||
object OfflinePlaybackHelper {
|
||||
fun playLink(url: String) {
|
||||
fun playLink(activity: Activity, url: String) {
|
||||
activity.navigate(
|
||||
R.id.global_to_navigation_player, GeneratorPlayer.newInstance(
|
||||
LinkGenerator(
|
||||
|
@ -23,15 +22,15 @@ object OfflinePlaybackHelper {
|
|||
)
|
||||
}
|
||||
|
||||
fun playUri(context: Context, uri: Uri) {
|
||||
val name = SafeFile.fromUri(context, uri)?.name()
|
||||
fun playUri(activity: Activity, uri: Uri) {
|
||||
val name = SafeFile.fromUri(activity, uri)?.name()
|
||||
activity.navigate(
|
||||
R.id.global_to_navigation_player, GeneratorPlayer.newInstance(
|
||||
DownloadFileGenerator(
|
||||
listOf(
|
||||
ExtractorUri(
|
||||
uri = uri,
|
||||
name = name ?: getString(context, R.string.downloaded_file),
|
||||
name = name ?: getString(activity, R.string.downloaded_file),
|
||||
// well not the same as a normal id, but we take it as users may want to
|
||||
// play downloaded files and save the location
|
||||
id = kotlin.runCatching { ContentUris.parseId(uri) }.getOrNull()?.hashCode()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue