Skip to content

Commit ba9fac9

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 23a0747 + a45f1d9 commit ba9fac9

18 files changed

Lines changed: 540 additions & 390 deletions

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ dependencies {
218218
implementation(libs.fragment.ktx)
219219
implementation(libs.bundles.lifecycle)
220220
implementation(libs.bundles.navigation)
221+
implementation(libs.kotlinx.collections.immutable)
221222

222223
// Design & UI
223224
implementation(libs.preference.ktx)

app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
362362
LinkGenerator(
363363
listOf(BasicLink(url, name)),
364364
extract = true,
365-
)
365+
id = url.hashCode()
366+
), 0
366367
)
367368
)
368369
} else if (safeURI(str)?.scheme == APP_STRING_RESUME_WATCHING) {
@@ -559,9 +560,11 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
559560
navView.isVisible = isNavVisible && !isLandscape()
560561
navHostFragment.apply {
561562
val marginPx = resources.getDimensionPixelSize(R.dimen.nav_rail_view_width)
562-
layoutParams = (navHostFragment.layoutParams as ViewGroup.MarginLayoutParams).apply {
563-
marginStart = if (isNavVisible && isLandscape() && isLayout(TV or EMULATOR)) marginPx else 0
564-
}
563+
layoutParams =
564+
(navHostFragment.layoutParams as ViewGroup.MarginLayoutParams).apply {
565+
marginStart =
566+
if (isNavVisible && isLandscape() && isLayout(TV or EMULATOR)) marginPx else 0
567+
}
565568
}
566569

567570
/**
@@ -570,7 +573,11 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
570573
* highlight the wrong one in UI.
571574
*/
572575
when (destination.id) {
573-
in listOf(R.id.navigation_downloads, R.id.navigation_download_child, R.id.navigation_download_queue) -> {
576+
in listOf(
577+
R.id.navigation_downloads,
578+
R.id.navigation_download_child,
579+
R.id.navigation_download_queue
580+
) -> {
574581
navRailView.menu.findItem(R.id.navigation_downloads).isChecked = true
575582
navView.menu.findItem(R.id.navigation_downloads).isChecked = true
576583
}

app/src/main/java/com/lagradost/cloudstream3/actions/temp/PlayMirrorAction.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ class PlayMirrorAction : VideoClickAction() {
3535
) {
3636
//Implemented a generator to handle the single
3737
val activity = context as? Activity ?: return
38+
val link = index?.let { result.links[it] }
3839
val generatorMirror = object : VideoGenerator<ResultEpisode>(listOf(video)) {
3940
override val hasCache: Boolean = false
4041
override val canSkipLoading: Boolean = false
42+
override fun getId(index: Int): Int = video.id
4143

4244
override suspend fun generateLinks(
4345
clearCache: Boolean,
@@ -47,7 +49,7 @@ class PlayMirrorAction : VideoClickAction() {
4749
offset: Int,
4850
isCasting: Boolean
4951
): Boolean {
50-
index?.let { callback(result.links[it] to null) }
52+
index?.let { callback(link to null) }
5153
result.subs.forEach { subtitle -> subtitleCallback(subtitle) }
5254
return true
5355
}
@@ -56,7 +58,7 @@ class PlayMirrorAction : VideoClickAction() {
5658
activity.navigate(
5759
R.id.global_to_navigation_player,
5860
GeneratorPlayer.newInstance(
59-
generatorMirror, result.syncData
61+
generatorMirror, 0, result.syncData
6062
)
6163
)
6264
}

app/src/main/java/com/lagradost/cloudstream3/ui/ControllerActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ class SelectSourceController(val view: ImageView, val activity: ControllerActivi
334334
}, subtitleCallback = {
335335
currentSubs.add(it)
336336
},
337+
offset = 0,
337338
isCasting = true
338339
)
339340
}

app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadButtonSetup.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ object DownloadButtonSetup {
162162
}
163163
act.navigate(
164164
R.id.global_to_navigation_player, GeneratorPlayer.newInstance(
165-
DownloadFileGenerator(items).apply { goto(items.indexOfFirst { it.id == click.data.id }) }
165+
DownloadFileGenerator(items),
166+
items.indexOfFirst { it.id == click.data.id }
166167
)
167168
)
168169
}

app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class DownloadFragment : BaseFragment<FragmentDownloadsBinding>(
148148
val size = cards.currentDownloads.size + cards.queue.size
149149
val context = binding.root.context
150150
val baseText = context.getString(R.string.download_queue)
151-
binding.downloadQueueText.text = if (size > 0) {
151+
binding.downloadQueueText.text = if (size > 0) {
152152
"$baseText (${cards.currentDownloads.size}/$size)"
153153
} else {
154154
baseText
@@ -349,7 +349,8 @@ class DownloadFragment : BaseFragment<FragmentDownloadsBinding>(
349349
listOf(BasicLink(url)),
350350
extract = true,
351351
refererUrl = referer,
352-
)
352+
id = url.hashCode()
353+
), 0
353354
)
354355
)
355356
dialog.dismissSafe(activity)

app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadFileGenerator.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ import com.lagradost.cloudstream3.utils.downloader.DownloadFileManagement.getFol
1414
import com.lagradost.cloudstream3.utils.downloader.VideoDownloadManager.getDownloadFileInfo
1515

1616
class DownloadFileGenerator(
17-
episodes: List<ExtractorUri>,
18-
currentIndex: Int = 0
19-
) : VideoGenerator<ExtractorUri>(episodes, currentIndex) {
17+
episodes: List<ExtractorUri>
18+
) : VideoGenerator<ExtractorUri>(episodes) {
2019
override val hasCache = false
2120
override val canSkipLoading = false
2221

22+
override fun getId(index: Int): Int? = this.videos.getOrNull(index)?.id
23+
2324
override suspend fun generateLinks(
2425
clearCache: Boolean,
2526
sourceTypes: Set<ExtractorLinkType>,
@@ -28,7 +29,7 @@ class DownloadFileGenerator(
2829
offset: Int,
2930
isCasting: Boolean
3031
): Boolean {
31-
val meta = getCurrent(offset) ?: return false
32+
val meta = videos.getOrNull(offset) ?: return false
3233

3334
if (meta.uri == Uri.EMPTY) {
3435
// We do this here so that we only load it when

app/src/main/java/com/lagradost/cloudstream3/ui/player/ExtractorLinkGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLinkType
66
class ExtractorLinkGenerator(
77
private val links: List<ExtractorLink>,
88
private val subtitles: List<SubtitleData>,
9-
) : NoVideoGenerator() {
9+
) : NoVideoGenerator(null) {
1010
override suspend fun generateLinks(
1111
clearCache: Boolean,
1212
sourceTypes: Set<ExtractorLinkType>,

0 commit comments

Comments
 (0)