forked from recloudstream/cloudstream
small fix
This commit is contained in:
parent
07eb5252a3
commit
440a9810be
8 changed files with 34 additions and 13 deletions
|
@ -119,19 +119,19 @@ abstract class MainAPI {
|
|||
)
|
||||
|
||||
open fun getMainPage(): HomePageResponse? {
|
||||
return null
|
||||
throw NotImplementedError()
|
||||
}
|
||||
|
||||
open fun search(query: String): List<SearchResponse>? {
|
||||
return null
|
||||
throw NotImplementedError()
|
||||
}
|
||||
|
||||
open fun quickSearch(query: String): List<SearchResponse>? {
|
||||
return null
|
||||
throw NotImplementedError()
|
||||
}
|
||||
|
||||
open fun load(url: String): LoadResponse? {
|
||||
return null
|
||||
throw NotImplementedError()
|
||||
}
|
||||
|
||||
/**Callback is fired once a link is found, will return true if method is executed successfully*/
|
||||
|
@ -141,7 +141,7 @@ abstract class MainAPI {
|
|||
subtitleCallback: (SubtitleFile) -> Unit,
|
||||
callback: (ExtractorLink) -> Unit
|
||||
): Boolean {
|
||||
return false
|
||||
throw NotImplementedError()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,9 @@ suspend fun <T> safeApiCall(
|
|||
is ErrorLoadingException -> {
|
||||
Resource.Failure(true, null, null, throwable.message ?: "Error loading, try again later.")
|
||||
}
|
||||
is NotImplementedError -> {
|
||||
Resource.Failure(false, null, null, "This operation is not implemented.")
|
||||
}
|
||||
else -> {
|
||||
val stackTraceMsg = throwable.localizedMessage + "\n\n" + throwable.stackTrace.joinToString(
|
||||
separator = "\n"
|
||||
|
|
|
@ -9,11 +9,13 @@ import com.lagradost.cloudstream3.ui.player.PlayerFragment
|
|||
import com.lagradost.cloudstream3.ui.player.UriData
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadHelper
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager
|
||||
|
||||
object DownloadButtonSetup {
|
||||
fun handleDownloadClick(activity: Activity?, headerName: String?, click: DownloadClickEvent) {
|
||||
val id = click.data.id
|
||||
if (click.data !is VideoDownloadHelper.DownloadEpisodeCached) return
|
||||
when (click.action) {
|
||||
DOWNLOAD_ACTION_DELETE_FILE -> {
|
||||
activity?.let { ctx ->
|
||||
|
@ -30,7 +32,15 @@ object DownloadButtonSetup {
|
|||
}
|
||||
|
||||
builder.setTitle("Delete File")
|
||||
builder.setMessage("This will permanently delete ${getNameFull(click.data.name,click.data.episode,click.data.season)}\nAre you sure?")
|
||||
builder.setMessage(
|
||||
"This will permanently delete ${
|
||||
getNameFull(
|
||||
click.data.name,
|
||||
click.data.episode,
|
||||
click.data.season
|
||||
)
|
||||
}\nAre you sure?"
|
||||
)
|
||||
.setTitle("Delete")
|
||||
.setPositiveButton("Delete", dialogClickListener)
|
||||
.setNegativeButton("Cancel", dialogClickListener)
|
||||
|
|
|
@ -29,7 +29,7 @@ data class VisualDownloadChildCached(
|
|||
val data: VideoDownloadHelper.DownloadEpisodeCached,
|
||||
)
|
||||
|
||||
data class DownloadClickEvent(val action: Int, val data: VideoDownloadHelper.DownloadEpisodeCached)
|
||||
data class DownloadClickEvent(val action: Int, val data: EasyDownloadButton.IMinimumData)
|
||||
|
||||
class DownloadChildAdapter(
|
||||
var cardList: List<VisualDownloadChildCached>,
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownload
|
|||
import com.lagradost.cloudstream3.utils.DOWNLOAD_EPISODE_CACHE
|
||||
import com.lagradost.cloudstream3.utils.DataStore.getFolderName
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadHelper
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager
|
||||
import kotlinx.android.synthetic.main.fragment_downloads.*
|
||||
|
||||
|
@ -107,6 +108,7 @@ class DownloadFragment : Fragment() {
|
|||
}
|
||||
},
|
||||
{ downloadClickEvent ->
|
||||
if (downloadClickEvent.data !is VideoDownloadHelper.DownloadEpisodeCached) return@DownloadHeaderAdapter
|
||||
handleDownloadClick(activity, downloadClickEvent.data.name, downloadClickEvent)
|
||||
if (downloadClickEvent.action == DOWNLOAD_ACTION_DELETE_FILE) {
|
||||
downloadsViewModel.updateList(requireContext())
|
||||
|
|
|
@ -16,6 +16,10 @@ import com.lagradost.cloudstream3.utils.VideoDownloadHelper
|
|||
import com.lagradost.cloudstream3.utils.VideoDownloadManager
|
||||
|
||||
class EasyDownloadButton : IDisposable {
|
||||
interface IMinimumData {
|
||||
val id : Int
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
try {
|
||||
downloadProgressEventListener?.let { VideoDownloadManager.downloadProgressEvent -= it }
|
||||
|
@ -34,7 +38,7 @@ class EasyDownloadButton : IDisposable {
|
|||
progressBar: ContentLoadingProgressBar,
|
||||
downloadButton: MaterialButton,
|
||||
textView: TextView?,
|
||||
data: VideoDownloadHelper.DownloadEpisodeCached,
|
||||
data: IMinimumData,
|
||||
clickCallback: (DownloadClickEvent) -> Unit,
|
||||
) {
|
||||
setUpDownloadButton(setupCurrentBytes, setupTotalBytes, progressBar, textView, data, downloadButton, {
|
||||
|
@ -49,7 +53,7 @@ class EasyDownloadButton : IDisposable {
|
|||
progressBar: ContentLoadingProgressBar,
|
||||
downloadImage: ImageView,
|
||||
textView: TextView?,
|
||||
data: VideoDownloadHelper.DownloadEpisodeCached,
|
||||
data: IMinimumData,
|
||||
clickCallback: (DownloadClickEvent) -> Unit,
|
||||
) {
|
||||
setUpDownloadButton(setupCurrentBytes, setupTotalBytes, progressBar, textView, data, downloadImage, {
|
||||
|
@ -62,7 +66,7 @@ class EasyDownloadButton : IDisposable {
|
|||
setupTotalBytes: Long?,
|
||||
progressBar: ContentLoadingProgressBar,
|
||||
textView: TextView?,
|
||||
data: VideoDownloadHelper.DownloadEpisodeCached,
|
||||
data: IMinimumData,
|
||||
downloadView: View,
|
||||
downloadImageChangeCallback: (Pair<Int, String>) -> Unit,
|
||||
clickCallback: (DownloadClickEvent) -> Unit,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.lagradost.cloudstream3.utils
|
||||
|
||||
import com.lagradost.cloudstream3.TvType
|
||||
import com.lagradost.cloudstream3.ui.download.EasyDownloadButton
|
||||
|
||||
object VideoDownloadHelper {
|
||||
data class DownloadEpisodeCached(
|
||||
|
@ -8,12 +9,12 @@ object VideoDownloadHelper {
|
|||
val poster: String?,
|
||||
val episode: Int,
|
||||
val season: Int?,
|
||||
val id: Int,
|
||||
override val id: Int,
|
||||
val parentId: Int,
|
||||
val rating: Int?,
|
||||
val descript: String?,
|
||||
val cacheTime: Long,
|
||||
)
|
||||
) : EasyDownloadButton.IMinimumData
|
||||
|
||||
data class DownloadHeaderCached(
|
||||
val apiName: String,
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
android:layout_gravity="end|center_vertical"
|
||||
android:src="@drawable/ic_baseline_arrow_forward_24"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="match_parent" android:contentDescription="@string/home_more_info">
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/home_more_info">
|
||||
</ImageView>
|
||||
</FrameLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue