Option to cancel all downloads for a series in dl/queue

This commit is contained in:
Jays2Kings 2021-05-08 15:22:39 -04:00
parent f1c624fe16
commit abb69921a2
5 changed files with 17 additions and 1 deletions

View File

@ -68,4 +68,8 @@ class DownloadBottomPresenter(val sheet: DownloadBottomSheet) {
fun cancelDownload(download: Download) {
downloadManager.deletePendingDownloads(download)
}
fun cancelDownloads(downloads: List<Download>) {
downloadManager.deletePendingDownloads(*downloads.toTypedArray())
}
}

View File

@ -283,6 +283,15 @@ class DownloadBottomSheet @JvmOverloads constructor(
val downloads = items.mapNotNull { it.download }
presenter.reorder(downloads)
}
R.id.cancel_series -> {
val download = adapter?.getItem(position)?.download ?: return
val allDownloadsForSeries = adapter?.currentItems
?.filter { download.manga.id == it.download.manga.id }
?.map(DownloadItem::download)
if (!allDownloadsForSeries.isNullOrEmpty()) {
presenter.cancelDownloads(allDownloadsForSeries)
}
}
}
}
}

View File

@ -53,7 +53,6 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
notifyDownloadedPages()
}
binding.downloadMenu.isVisible = flexibleAdapterPosition != 0 || flexibleAdapterPosition != adapter.itemCount - 1
binding.downloadMenu.setVectorCompat(
R.drawable.ic_more_vert_24dp,
view.context

View File

@ -5,4 +5,7 @@
<item android:id="@+id/move_to_bottom"
android:title="@string/move_to_bottom" />
<item android:id="@+id/cancel_series"
android:title="@string/cancel_all_for_series" />
</menu>

View File

@ -763,6 +763,7 @@
<string name="download_queue">Download queue</string>
<string name="downloading_">Downloading: %1$s</string>
<string name="cancel_all">Cancel all</string>
<string name="cancel_all_for_series">Cancel all for this series</string>
<string name="downloaded">Downloaded</string>
<string name="not_downloaded">Not downloaded</string>
<string name="downloading">Downloading</string>