From 77778bdbb6ba7d3a28313819a282c8247cfe990f Mon Sep 17 00:00:00 2001 From: LagradOst Date: Sun, 25 Jul 2021 16:25:09 +0200 Subject: [PATCH] download movie stuff --- .../lagradost/cloudstream3/MainActivity.kt | 8 +- .../animeproviders/DubbedAnimeProvider.kt | 2 +- .../ui/download/DownloadButtonSetup.kt | 6 +- .../ui/download/DownloadChildAdapter.kt | 84 ------------------- .../ui/download/DownloadChildFragment.kt | 21 ++--- .../ui/download/DownloadFragment.kt | 48 ++++++++--- .../ui/download/DownloadHeaderAdapter.kt | 46 ++++++++-- .../ui/download/DownloadViewModel.kt | 44 ++++++---- .../cloudstream3/ui/result/ResultFragment.kt | 2 +- .../cloudstream3/ui/result/ResultViewModel.kt | 2 +- .../utils/VideoDownloadManager.kt | 5 +- app/src/main/res/drawable/netflix_pause.xml | 4 +- .../res/layout/download_child_episode.xml | 3 +- .../res/layout/download_header_episode.xml | 43 +++++++++- app/src/main/res/layout/result_episode.xml | 3 +- .../main/res/layout/result_episode_large.xml | 4 +- 16 files changed, 176 insertions(+), 149 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index d5d1f878..955191c7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -205,6 +205,9 @@ class MainActivity : AppCompatActivity() { // this.startService(mServiceIntent) //} //settingsManager.getBoolean("disable_automatic_data_downloads", true) && + + // TODO RETURN TO TRUE + /* if (isUsingMobileData()) { Toast.makeText(this, "Downloads not resumed on mobile data", Toast.LENGTH_LONG).show() } else { @@ -226,7 +229,10 @@ class MainActivity : AppCompatActivity() { resumeQueue?.sortedBy { it.index }?.forEach { VideoDownloadManager.downloadFromResume(this, it.pkg) } - } + }*/ + + + /* val castContext = CastContext.getSharedInstance(applicationContext) fun buildMediaQueueItem(video: String): MediaQueueItem { diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt index 037cb62b..a9a8a91d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt @@ -214,7 +214,7 @@ class DubbedAnimeProvider : MainAPI() { val img = fixUrl(document.select("div.fkimgs > img").attr("src")) return AnimeLoadResponse( - null, null, title, slug, this.name, TvType.Anime, img, year, ArrayList(episodes), null, null, descript, + null, null, title, "$mainUrl/$slug", this.name, TvType.Anime, img, year, ArrayList(episodes), null, null, descript, ) } } 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 2e408835..af35652a 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 @@ -83,7 +83,7 @@ object DownloadButtonSetup { info.path.toString(), click.data.id, headerName ?: "null", - click.data.episode, + if (click.data.episode <= 0) null else click.data.episode, click.data.season ), act.getViewPos(click.data.id)?.position ?: 0 @@ -194,8 +194,8 @@ object DownloadButtonSetup { Pair(DOWNLOAD_ACTION_DELETE_FILE, R.string.popup_delete_file), ) - // DON'T RESUME A DOWNLOADED FILE - if (lastState != VideoDownloadManager.DownloadType.IsDone && ((currentBytes * 100 / totalBytes) < 98)) { + // DON'T RESUME A DOWNLOADED FILE lastState != VideoDownloadManager.DownloadType.IsDone && + if ((currentBytes * 100 / totalBytes) < 98) { list.add( if (lastState == VideoDownloadManager.DownloadType.IsDownloading) Pair(DOWNLOAD_ACTION_PAUSE_DOWNLOAD, R.string.popup_pause_download) 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 73061721..a360b9e9 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 @@ -99,94 +99,10 @@ class DownloadChildAdapter( card.data, clickCallback ) - /* - val totalMbString = "%.1f".format(card.totalBytes / 1000000f) - - var lastState: VideoDownloadManager.DownloadType? = null - var currentBytes: Long = card.currentBytes - - fun changeDownloadImage(state: VideoDownloadManager.DownloadType) { - runOnMainThread { - val img = when (state) { - VideoDownloadManager.DownloadType.IsPaused -> R.drawable.ic_baseline_play_arrow_24 - VideoDownloadManager.DownloadType.IsDownloading -> R.drawable.netflix_pause - else -> R.drawable.ic_baseline_delete_outline_24 - } - downloadImage?.setImageResource(img) - } - } - - fun fixDownloadedBytes(setCurrentBytes: Long, animate : Boolean) { - currentBytes = setCurrentBytes - runOnMainThread { - val currentMbString = "%.1f".format(currentBytes / 1000000f) - - extraInfo?.text = - "${currentMbString}MB / ${totalMbString}MB" - - progressBarDownload?.let { bar -> - bar.max = (card.totalBytes / 1000).toInt() - - if(animate) { - val animation: ObjectAnimator = ObjectAnimator.ofInt( - bar, - "progress", - bar.progress, - (currentBytes / 1000).toInt() - ) - animation.duration = 500 - animation.setAutoCancel(true) - animation.interpolator = DecelerateInterpolator() - animation.start() - } else { - bar.progress = (currentBytes / 1000).toInt() - } - } - } - } - fixDownloadedBytes(card.currentBytes, false) - changeDownloadImage(getDownloadState(card.data.id)) - - VideoDownloadManager.downloadProgressEvent += { downloadData -> - if (card.data.id == downloadData.first) { - fixDownloadedBytes(downloadData.second, true) - } - } - - VideoDownloadManager.downloadStatusEvent += { downloadData -> - if (card.data.id == downloadData.first) { - if (lastState != downloadData.second) { // TO PREVENT WASTING UI TIME - lastState = downloadData.second - changeDownloadImage(downloadData.second) - } - } - } holder.setOnClickListener { clickCallback.invoke(DownloadClickEvent(DOWNLOAD_ACTION_PLAY_FILE, d)) } - - downloadImage.setOnClickListener { - val list = arrayListOf( - Pair(DOWNLOAD_ACTION_DELETE_FILE, R.string.popup_delete_file), - ) - - // DON'T RESUME A DOWNLOADED FILE - if (lastState != VideoDownloadManager.DownloadType.IsDone && (currentBytes * 100 / card.totalBytes < 98)) { - list.add( - if (lastState == VideoDownloadManager.DownloadType.IsDownloading) - Pair(DOWNLOAD_ACTION_PAUSE_DOWNLOAD, R.string.popup_pause_download) - else - Pair(DOWNLOAD_ACTION_RESUME_DOWNLOAD, R.string.popup_resume_download) - ) - } - - it.popupMenuNoIcons( - list - ) { - clickCallback.invoke(DownloadClickEvent(itemId, d)) - } - }*/ } } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildFragment.kt index 4cfb814d..2115f4b8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildFragment.kt @@ -1,26 +1,18 @@ package com.lagradost.cloudstream3.ui.download -import android.app.Activity -import android.content.Context import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.appcompat.app.AppCompatActivity -import androidx.core.content.ContentProviderCompat.requireContext import androidx.fragment.app.Fragment -import androidx.fragment.app.FragmentActivity import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.UIHelper.fixPaddingStatusbar import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick -import com.lagradost.cloudstream3.ui.player.PlayerFragment -import com.lagradost.cloudstream3.ui.player.UriData import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.getKeys -import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos import com.lagradost.cloudstream3.utils.VideoDownloadHelper import com.lagradost.cloudstream3.utils.VideoDownloadManager import kotlinx.android.synthetic.main.fragment_child_downloads.* @@ -88,12 +80,17 @@ class DownloadChildFragment : Fragment() { ArrayList(), ) { click -> handleDownloadClick(activity, name, click) - when (click.action) { - DOWNLOAD_ACTION_DELETE_FILE -> { - updateList(folder) - } + } + + VideoDownloadManager.downloadDeleteEvent += { id -> + val list = (download_child_list?.adapter as DownloadChildAdapter?)?.cardList + if (list != null) { + if (list.any { it.data.id == id }) { + updateList(folder) } } + } + download_child_list.adapter = adapter download_child_list.layoutManager = GridLayoutManager(context, 1) 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 2aafaa08..a54afc73 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 @@ -16,15 +16,16 @@ import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.UIHelper.fixPaddingStatusbar import com.lagradost.cloudstream3.isMovieType import com.lagradost.cloudstream3.mvvm.observe +import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick import com.lagradost.cloudstream3.ui.result.ResultFragment import com.lagradost.cloudstream3.utils.DOWNLOAD_EPISODE_CACHE import com.lagradost.cloudstream3.utils.DataStore.getFolderName +import com.lagradost.cloudstream3.utils.VideoDownloadManager +import kotlinx.android.synthetic.main.fragment_child_downloads.* import kotlinx.android.synthetic.main.fragment_downloads.* import kotlinx.android.synthetic.main.fragment_result.* - class DownloadFragment : Fragment() { - private lateinit var downloadsViewModel: DownloadViewModel private fun getBytesAsText(bytes: Long): String { @@ -40,6 +41,11 @@ class DownloadFragment : Fragment() { this.layoutParams = param } + fun setList(list : List) { + (download_list?.adapter as DownloadHeaderAdapter? ?: return).cardList = list + (download_list?.adapter as DownloadHeaderAdapter? ?: return).notifyDataSetChanged() + } + @SuppressLint("SetTextI18n") override fun onCreateView( inflater: LayoutInflater, @@ -52,8 +58,7 @@ class DownloadFragment : Fragment() { text_no_downloads.text = it } observe(downloadsViewModel.headerCards) { - (download_list?.adapter as DownloadHeaderAdapter? ?: return@observe).cardList = it - (download_list?.adapter as DownloadHeaderAdapter? ?: return@observe).notifyDataSetChanged() + setList(it) } observe(downloadsViewModel.availableBytes) { download_free_txt?.text = "Free • ${getBytesAsText(it)}GB" @@ -76,19 +81,36 @@ class DownloadFragment : Fragment() { val adapter: RecyclerView.Adapter = DownloadHeaderAdapter( ArrayList(), - ) { click -> - if(click.data.type.isMovieType()) { - //TODO MOVIE - } - else { - val folder = getFolderName(DOWNLOAD_EPISODE_CACHE, click.data.id.toString()) - val navController = activity?.findNavController(R.id.nav_host_fragment) - navController?.navigate(R.id.navigation_download_child, Bundle().apply { + { click -> + if (click.data.type.isMovieType()) { + //wont be called + } else { + val folder = getFolderName(DOWNLOAD_EPISODE_CACHE, click.data.id.toString()) + val navController = activity?.findNavController(R.id.nav_host_fragment) + navController?.navigate(R.id.navigation_download_child, Bundle().apply { putString("folder", folder) putString("name", click.data.name) - }) + }) + } + }, + { downloadClickEvent -> + handleDownloadClick(activity, downloadClickEvent.data.name, downloadClickEvent) + if(downloadClickEvent.action == DOWNLOAD_ACTION_DELETE_FILE) { + downloadsViewModel.updateList(requireContext()) + } + } + ) + + VideoDownloadManager.downloadDeleteEvent += { id -> + val list = (download_list?.adapter as DownloadHeaderAdapter?)?.cardList + if (list != null) { + if (list.any { it.data.id == id }) { + setList(ArrayList()) + downloadsViewModel.updateList(requireContext()) } } + } + download_list.adapter = adapter download_list.layoutManager = GridLayoutManager(context, 1) downloadsViewModel.updateList(requireContext()) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadHeaderAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadHeaderAdapter.kt index c1b4b831..aa2c8df6 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadHeaderAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadHeaderAdapter.kt @@ -7,11 +7,13 @@ import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView import androidx.cardview.widget.CardView +import androidx.core.widget.ContentLoadingProgressBar import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.bumptech.glide.load.model.GlideUrl import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.isMovieType +import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.setUpButton import com.lagradost.cloudstream3.utils.VideoDownloadHelper import kotlinx.android.synthetic.main.download_header_episode.view.* @@ -19,7 +21,9 @@ data class VisualDownloadHeaderCached( val currentOngoingDownloads: Int, val totalDownloads: Int, val totalBytes: Long, + val currentBytes: Long, val data: VideoDownloadHelper.DownloadHeaderCached, + val child: VideoDownloadHelper.DownloadEpisodeCached?, ) data class DownloadHeaderClickEvent(val action: Int, val data: VideoDownloadHelper.DownloadHeaderCached) @@ -27,13 +31,15 @@ data class DownloadHeaderClickEvent(val action: Int, val data: VideoDownloadHelp class DownloadHeaderAdapter( var cardList: List, private val clickCallback: (DownloadHeaderClickEvent) -> Unit, + private val movieClickCallback: (DownloadClickEvent) -> Unit, ) : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return DownloadHeaderViewHolder( LayoutInflater.from(parent.context).inflate(R.layout.download_header_episode, parent, false), - clickCallback + clickCallback, + movieClickCallback ) } @@ -53,12 +59,17 @@ class DownloadHeaderAdapter( constructor( itemView: View, private val clickCallback: (DownloadHeaderClickEvent) -> Unit, + private val movieClickCallback: (DownloadClickEvent) -> Unit, ) : RecyclerView.ViewHolder(itemView) { private val poster: ImageView = itemView.download_header_poster private val title: TextView = itemView.download_header_title private val extraInfo: TextView = itemView.download_header_info private val holder: CardView = itemView.episode_holder + private val downloadBar: ContentLoadingProgressBar = itemView.download_header_progress_downloaded + private val downloadImage: ImageView = itemView.download_header_episode_download + private val normalImage: ImageView = itemView.download_header_goto_child + @SuppressLint("SetTextI18n") fun bind(card: VisualDownloadHeaderCached) { val d = card.data @@ -77,13 +88,36 @@ class DownloadHeaderAdapter( title.text = d.name val mbString = "%.1f".format(card.totalBytes / 1000000f) - extraInfo.text = - if (d.type.isMovieType()) - "${mbString}MB" else + //val isMovie = d.type.isMovieType() + if (card.child != null) { + downloadBar.visibility = View.VISIBLE + downloadImage.visibility = View.VISIBLE + normalImage.visibility = View.GONE + + setUpButton( + card.currentBytes, + card.totalBytes, + downloadBar, + downloadImage, + extraInfo, + card.child, + movieClickCallback + ) + + holder.setOnClickListener { + movieClickCallback.invoke(DownloadClickEvent(DOWNLOAD_ACTION_PLAY_FILE, card.child)) + } + } else { + downloadBar.visibility = View.GONE + downloadImage.visibility = View.GONE + normalImage.visibility = View.VISIBLE + + extraInfo.text = "${card.totalDownloads} Episode${if (card.totalDownloads == 1) "" else "s"} | ${mbString}MB" - holder.setOnClickListener { - clickCallback.invoke(DownloadHeaderClickEvent(0, d)) + holder.setOnClickListener { + clickCallback.invoke(DownloadHeaderClickEvent(0, d)) + } } } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadViewModel.kt index bf1c72ff..7a5ef0ff 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadViewModel.kt @@ -7,8 +7,11 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.lagradost.cloudstream3.TvType +import com.lagradost.cloudstream3.isMovieType import com.lagradost.cloudstream3.utils.DOWNLOAD_EPISODE_CACHE import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE +import com.lagradost.cloudstream3.utils.DataStore.getFolderName import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.getKeys import com.lagradost.cloudstream3.utils.VideoDownloadHelper @@ -38,11 +41,14 @@ class DownloadViewModel : ViewModel() { fun updateList(context: Context) = viewModelScope.launch { val children = withContext(Dispatchers.IO) { val headers = context.getKeys(DOWNLOAD_EPISODE_CACHE) - headers.mapNotNull { context.getKey(it) }.distinctBy { it.id } // Remove duplicates + headers.mapNotNull { context.getKey(it) } + .distinctBy { it.id } // Remove duplicates } // parentId : bytes - val bytesUsedByChild = HashMap() + val totalBytesUsedByChild = HashMap() + // parentId : bytes + val currentBytesUsedByChild = HashMap() // parentId : downloadsCount val totalDownloads = HashMap() @@ -51,19 +57,13 @@ class DownloadViewModel : ViewModel() { for (c in children) { val childFile = VideoDownloadManager.getDownloadFileInfoAndUpdateSettings(context, c.id) ?: continue - if(childFile.fileLength <= 1) continue + if (childFile.fileLength <= 1) continue val len = childFile.totalBytes - if (bytesUsedByChild.containsKey(c.parentId)) { - bytesUsedByChild[c.parentId] = bytesUsedByChild[c.parentId]?.plus(len) ?: len - } else { - bytesUsedByChild[c.parentId] = len - } + val flen = childFile.fileLength - if (totalDownloads.containsKey(c.parentId)) { - totalDownloads[c.parentId] = totalDownloads[c.parentId]?.plus(1) ?: 1 - } else { - totalDownloads[c.parentId] = 1 - } + totalBytesUsedByChild[c.parentId] = totalBytesUsedByChild[c.parentId]?.plus(len) ?: len + currentBytesUsedByChild[c.parentId] = currentBytesUsedByChild[c.parentId]?.plus(flen) ?: flen + totalDownloads[c.parentId] = totalDownloads[c.parentId]?.plus(1) ?: 1 } } @@ -75,9 +75,21 @@ class DownloadViewModel : ViewModel() { val visual = withContext(Dispatchers.IO) { cached.mapNotNull { // TODO FIX val downloads = totalDownloads[it.id] ?: 0 - val bytes = bytesUsedByChild[it.id] ?: 0 - if(bytes <= 0 || downloads <= 0) return@mapNotNull null - VisualDownloadHeaderCached(0, downloads, bytes, it) + val bytes = totalBytesUsedByChild[it.id] ?: 0 + val currentBytes = currentBytesUsedByChild[it.id] ?: 0 + if (bytes <= 0 || downloads <= 0) return@mapNotNull null + val movieEpisode = if (!it.type.isMovieType()) null else context.getKey( + DOWNLOAD_EPISODE_CACHE, + getFolderName(it.id.toString(), it.id.toString()) + ) + VisualDownloadHeaderCached( + 0, + downloads, + bytes, + currentBytes, + it, + movieEpisode + ) } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index f6b7a3ca..68311fe3 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -380,7 +380,7 @@ class ResultFragment : Fragment() { val meta = VideoDownloadManager.DownloadEpisodeMetadata( episodeClick.data.id, titleName, - apiName ?: return, + apiName, episodeClick.data.poster ?: currentPoster, episodeClick.data.name, if (isMovie) null else episodeClick.data.season, diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt index 02125ac9..0a222b5c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt @@ -171,7 +171,7 @@ class ResultViewModel : ViewModel() { null, d.dataUrl, d.apiName, - (mainId + 1), + (mainId), // HAS SAME ID 0, null, null, diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt index f42dde77..988aab21 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt @@ -143,6 +143,7 @@ object VideoDownloadManager { val downloadStatus = HashMap() val downloadStatusEvent = Event>() + val downloadDeleteEvent = Event() val downloadEvent = Event>() val downloadProgressEvent = Event>() val downloadQueue = LinkedList() @@ -427,6 +428,7 @@ object VideoDownloadManager { } else { if (!File(normalPath).delete()) return ERROR_DELETING_FILE } + downloadDeleteEvent.invoke(ep.id) return SUCCESS_STOPPED } @@ -716,10 +718,11 @@ object VideoDownloadManager { } private fun deleteFile(context: Context, id: Int): Boolean { + val info = context.getKey(KEY_DOWNLOAD_INFO, id.toString()) ?: return false downloadEvent.invoke(Pair(id, DownloadActionType.Stop)) downloadProgressEvent.invoke(Triple(id, 0, 0)) downloadStatusEvent.invoke(Pair(id, DownloadType.IsStopped)) - val info = context.getKey(KEY_DOWNLOAD_INFO, id.toString()) ?: return false + downloadDeleteEvent.invoke(id) if (isScopedStorage()) { val cr = context.contentResolver ?: return false diff --git a/app/src/main/res/drawable/netflix_pause.xml b/app/src/main/res/drawable/netflix_pause.xml index 1a8965b8..0fbd7062 100644 --- a/app/src/main/res/drawable/netflix_pause.xml +++ b/app/src/main/res/drawable/netflix_pause.xml @@ -1,6 +1,6 @@ - + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/result_episode.xml b/app/src/main/res/layout/result_episode.xml index 85d1d9c9..ec7550b7 100644 --- a/app/src/main/res/layout/result_episode.xml +++ b/app/src/main/res/layout/result_episode.xml @@ -86,7 +86,8 @@ android:visibility="visible" android:layout_marginEnd="10dp" android:layout_marginStart="10dp" - android:layout_height="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" android:padding="2dp" android:layout_width="30dp" android:id="@+id/result_episode_download" diff --git a/app/src/main/res/layout/result_episode_large.xml b/app/src/main/res/layout/result_episode_large.xml index 8f00b63a..db0ca4da 100644 --- a/app/src/main/res/layout/result_episode_large.xml +++ b/app/src/main/res/layout/result_episode_large.xml @@ -101,7 +101,8 @@ android:visibility="visible" android:layout_marginEnd="10dp" android:layout_marginStart="10dp" - android:layout_height="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" android:padding="2dp" android:layout_width="30dp" android:id="@+id/result_episode_download" @@ -109,7 +110,6 @@ android:src="@drawable/ic_baseline_play_arrow_24" android:contentDescription="@string/download_descript"/> -