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? { |     open fun getMainPage(): HomePageResponse? { | ||||||
|         return null |         throw NotImplementedError() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     open fun search(query: String): List<SearchResponse>? { |     open fun search(query: String): List<SearchResponse>? { | ||||||
|         return null |         throw NotImplementedError() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     open fun quickSearch(query: String): List<SearchResponse>? { |     open fun quickSearch(query: String): List<SearchResponse>? { | ||||||
|         return null |         throw NotImplementedError() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     open fun load(url: String): LoadResponse? { |     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*/ |     /**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, |         subtitleCallback: (SubtitleFile) -> Unit, | ||||||
|         callback: (ExtractorLink) -> Unit |         callback: (ExtractorLink) -> Unit | ||||||
|     ): Boolean { |     ): Boolean { | ||||||
|         return false |         throw NotImplementedError() | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -72,6 +72,9 @@ suspend fun <T> safeApiCall( | ||||||
|                 is ErrorLoadingException -> { |                 is ErrorLoadingException -> { | ||||||
|                     Resource.Failure(true, null, null, throwable.message ?: "Error loading, try again later.") |                     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 -> { |                 else -> { | ||||||
|                     val stackTraceMsg = throwable.localizedMessage + "\n\n" + throwable.stackTrace.joinToString( |                     val stackTraceMsg = throwable.localizedMessage + "\n\n" + throwable.stackTrace.joinToString( | ||||||
|                         separator = "\n" |                         separator = "\n" | ||||||
|  |  | ||||||
|  | @ -9,11 +9,13 @@ import com.lagradost.cloudstream3.ui.player.PlayerFragment | ||||||
| import com.lagradost.cloudstream3.ui.player.UriData | import com.lagradost.cloudstream3.ui.player.UriData | ||||||
| import com.lagradost.cloudstream3.utils.AppUtils.getNameFull | import com.lagradost.cloudstream3.utils.AppUtils.getNameFull | ||||||
| import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos | import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos | ||||||
|  | import com.lagradost.cloudstream3.utils.VideoDownloadHelper | ||||||
| import com.lagradost.cloudstream3.utils.VideoDownloadManager | import com.lagradost.cloudstream3.utils.VideoDownloadManager | ||||||
| 
 | 
 | ||||||
| object DownloadButtonSetup { | object DownloadButtonSetup { | ||||||
|     fun handleDownloadClick(activity: Activity?, headerName: String?, click: DownloadClickEvent) { |     fun handleDownloadClick(activity: Activity?, headerName: String?, click: DownloadClickEvent) { | ||||||
|         val id = click.data.id |         val id = click.data.id | ||||||
|  |         if (click.data !is VideoDownloadHelper.DownloadEpisodeCached) return | ||||||
|         when (click.action) { |         when (click.action) { | ||||||
|             DOWNLOAD_ACTION_DELETE_FILE -> { |             DOWNLOAD_ACTION_DELETE_FILE -> { | ||||||
|                 activity?.let { ctx -> |                 activity?.let { ctx -> | ||||||
|  | @ -30,7 +32,15 @@ object DownloadButtonSetup { | ||||||
|                         } |                         } | ||||||
| 
 | 
 | ||||||
|                     builder.setTitle("Delete File") |                     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") |                         .setTitle("Delete") | ||||||
|                         .setPositiveButton("Delete", dialogClickListener) |                         .setPositiveButton("Delete", dialogClickListener) | ||||||
|                         .setNegativeButton("Cancel", dialogClickListener) |                         .setNegativeButton("Cancel", dialogClickListener) | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ data class VisualDownloadChildCached( | ||||||
|     val data: VideoDownloadHelper.DownloadEpisodeCached, |     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( | class DownloadChildAdapter( | ||||||
|     var cardList: List<VisualDownloadChildCached>, |     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.DOWNLOAD_EPISODE_CACHE | ||||||
| import com.lagradost.cloudstream3.utils.DataStore.getFolderName | import com.lagradost.cloudstream3.utils.DataStore.getFolderName | ||||||
| import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard | import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard | ||||||
|  | import com.lagradost.cloudstream3.utils.VideoDownloadHelper | ||||||
| import com.lagradost.cloudstream3.utils.VideoDownloadManager | import com.lagradost.cloudstream3.utils.VideoDownloadManager | ||||||
| import kotlinx.android.synthetic.main.fragment_downloads.* | import kotlinx.android.synthetic.main.fragment_downloads.* | ||||||
| 
 | 
 | ||||||
|  | @ -107,6 +108,7 @@ class DownloadFragment : Fragment() { | ||||||
|                     } |                     } | ||||||
|                 }, |                 }, | ||||||
|                 { downloadClickEvent -> |                 { downloadClickEvent -> | ||||||
|  |                     if (downloadClickEvent.data !is VideoDownloadHelper.DownloadEpisodeCached) return@DownloadHeaderAdapter | ||||||
|                     handleDownloadClick(activity, downloadClickEvent.data.name, downloadClickEvent) |                     handleDownloadClick(activity, downloadClickEvent.data.name, downloadClickEvent) | ||||||
|                     if (downloadClickEvent.action == DOWNLOAD_ACTION_DELETE_FILE) { |                     if (downloadClickEvent.action == DOWNLOAD_ACTION_DELETE_FILE) { | ||||||
|                         downloadsViewModel.updateList(requireContext()) |                         downloadsViewModel.updateList(requireContext()) | ||||||
|  |  | ||||||
|  | @ -16,6 +16,10 @@ import com.lagradost.cloudstream3.utils.VideoDownloadHelper | ||||||
| import com.lagradost.cloudstream3.utils.VideoDownloadManager | import com.lagradost.cloudstream3.utils.VideoDownloadManager | ||||||
| 
 | 
 | ||||||
| class EasyDownloadButton : IDisposable { | class EasyDownloadButton : IDisposable { | ||||||
|  |     interface IMinimumData { | ||||||
|  |         val id : Int | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     override fun dispose() { |     override fun dispose() { | ||||||
|         try { |         try { | ||||||
|             downloadProgressEventListener?.let { VideoDownloadManager.downloadProgressEvent -= it } |             downloadProgressEventListener?.let { VideoDownloadManager.downloadProgressEvent -= it } | ||||||
|  | @ -34,7 +38,7 @@ class EasyDownloadButton : IDisposable { | ||||||
|         progressBar: ContentLoadingProgressBar, |         progressBar: ContentLoadingProgressBar, | ||||||
|         downloadButton: MaterialButton, |         downloadButton: MaterialButton, | ||||||
|         textView: TextView?, |         textView: TextView?, | ||||||
|         data: VideoDownloadHelper.DownloadEpisodeCached, |         data: IMinimumData, | ||||||
|         clickCallback: (DownloadClickEvent) -> Unit, |         clickCallback: (DownloadClickEvent) -> Unit, | ||||||
|     ) { |     ) { | ||||||
|         setUpDownloadButton(setupCurrentBytes, setupTotalBytes, progressBar, textView, data, downloadButton, { |         setUpDownloadButton(setupCurrentBytes, setupTotalBytes, progressBar, textView, data, downloadButton, { | ||||||
|  | @ -49,7 +53,7 @@ class EasyDownloadButton : IDisposable { | ||||||
|         progressBar: ContentLoadingProgressBar, |         progressBar: ContentLoadingProgressBar, | ||||||
|         downloadImage: ImageView, |         downloadImage: ImageView, | ||||||
|         textView: TextView?, |         textView: TextView?, | ||||||
|         data: VideoDownloadHelper.DownloadEpisodeCached, |         data: IMinimumData, | ||||||
|         clickCallback: (DownloadClickEvent) -> Unit, |         clickCallback: (DownloadClickEvent) -> Unit, | ||||||
|     ) { |     ) { | ||||||
|         setUpDownloadButton(setupCurrentBytes, setupTotalBytes, progressBar, textView, data, downloadImage, { |         setUpDownloadButton(setupCurrentBytes, setupTotalBytes, progressBar, textView, data, downloadImage, { | ||||||
|  | @ -62,7 +66,7 @@ class EasyDownloadButton : IDisposable { | ||||||
|         setupTotalBytes: Long?, |         setupTotalBytes: Long?, | ||||||
|         progressBar: ContentLoadingProgressBar, |         progressBar: ContentLoadingProgressBar, | ||||||
|         textView: TextView?, |         textView: TextView?, | ||||||
|         data: VideoDownloadHelper.DownloadEpisodeCached, |         data: IMinimumData, | ||||||
|         downloadView: View, |         downloadView: View, | ||||||
|         downloadImageChangeCallback: (Pair<Int, String>) -> Unit, |         downloadImageChangeCallback: (Pair<Int, String>) -> Unit, | ||||||
|         clickCallback: (DownloadClickEvent) -> Unit, |         clickCallback: (DownloadClickEvent) -> Unit, | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| package com.lagradost.cloudstream3.utils | package com.lagradost.cloudstream3.utils | ||||||
| 
 | 
 | ||||||
| import com.lagradost.cloudstream3.TvType | import com.lagradost.cloudstream3.TvType | ||||||
|  | import com.lagradost.cloudstream3.ui.download.EasyDownloadButton | ||||||
| 
 | 
 | ||||||
| object VideoDownloadHelper { | object VideoDownloadHelper { | ||||||
|     data class DownloadEpisodeCached( |     data class DownloadEpisodeCached( | ||||||
|  | @ -8,12 +9,12 @@ object VideoDownloadHelper { | ||||||
|         val poster: String?, |         val poster: String?, | ||||||
|         val episode: Int, |         val episode: Int, | ||||||
|         val season: Int?, |         val season: Int?, | ||||||
|         val id: Int, |         override val id: Int, | ||||||
|         val parentId: Int, |         val parentId: Int, | ||||||
|         val rating: Int?, |         val rating: Int?, | ||||||
|         val descript: String?, |         val descript: String?, | ||||||
|         val cacheTime: Long, |         val cacheTime: Long, | ||||||
|     ) |     ) : EasyDownloadButton.IMinimumData | ||||||
| 
 | 
 | ||||||
|     data class DownloadHeaderCached( |     data class DownloadHeaderCached( | ||||||
|         val apiName: String, |         val apiName: String, | ||||||
|  |  | ||||||
|  | @ -28,7 +28,8 @@ | ||||||
|                 android:layout_gravity="end|center_vertical" |                 android:layout_gravity="end|center_vertical" | ||||||
|                 android:src="@drawable/ic_baseline_arrow_forward_24" |                 android:src="@drawable/ic_baseline_arrow_forward_24" | ||||||
|                 android:layout_width="30dp" |                 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> |         </ImageView> | ||||||
|     </FrameLayout> |     </FrameLayout> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue