From 440a9810be6f713788dedc454285daef7cc6339c Mon Sep 17 00:00:00 2001 From: LagradOst Date: Sat, 21 Aug 2021 23:06:24 +0200 Subject: [PATCH] small fix --- .../main/java/com/lagradost/cloudstream3/MainAPI.kt | 10 +++++----- .../lagradost/cloudstream3/mvvm/ArchComponentExt.kt | 3 +++ .../cloudstream3/ui/download/DownloadButtonSetup.kt | 12 +++++++++++- .../cloudstream3/ui/download/DownloadChildAdapter.kt | 2 +- .../cloudstream3/ui/download/DownloadFragment.kt | 2 ++ .../cloudstream3/ui/download/EasyDownloadButton.kt | 10 +++++++--- .../cloudstream3/utils/VideoDownloadHelper.kt | 5 +++-- app/src/main/res/layout/homepage_parent.xml | 3 ++- 8 files changed, 34 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt index 2804d5e8..87092480 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt @@ -119,19 +119,19 @@ abstract class MainAPI { ) open fun getMainPage(): HomePageResponse? { - return null + throw NotImplementedError() } open fun search(query: String): List? { - return null + throw NotImplementedError() } open fun quickSearch(query: String): List? { - 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() } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt b/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt index 73c02145..ba746b90 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt @@ -72,6 +72,9 @@ suspend fun 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" diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadButtonSetup.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadButtonSetup.kt index 3cccbdc2..688fa287 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadButtonSetup.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadButtonSetup.kt @@ -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) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildAdapter.kt index 63461aa1..ca946f61 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildAdapter.kt @@ -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, diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt index 79a55e73..25c9f4ce 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt @@ -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()) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/EasyDownloadButton.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/EasyDownloadButton.kt index 5515154a..42056773 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/EasyDownloadButton.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/EasyDownloadButton.kt @@ -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) -> Unit, clickCallback: (DownloadClickEvent) -> Unit, diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadHelper.kt index 5adda5b6..002428c7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadHelper.kt @@ -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, diff --git a/app/src/main/res/layout/homepage_parent.xml b/app/src/main/res/layout/homepage_parent.xml index 2a077139..bae8831a 100644 --- a/app/src/main/res/layout/homepage_parent.xml +++ b/app/src/main/res/layout/homepage_parent.xml @@ -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">