mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-14 06:22:49 +01:00
Add cancel all for series in download queue (#5062)
Co-authored-by: Jays2Kings <jays@outlook.com>
This commit is contained in:
parent
5700c7a0c7
commit
7ba43ae5c2
@ -203,6 +203,15 @@ class DownloadManager(private val context: Context) {
|
|||||||
deleteChapters(listOf(download.chapter), download.manga, download.source)
|
deleteChapters(listOf(download.chapter), download.manga, download.source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun deletePendingDownloads(vararg downloads: Download) {
|
||||||
|
val downloadsByManga = downloads.groupBy { it.manga.id }
|
||||||
|
downloadsByManga.map { entry ->
|
||||||
|
val manga = entry.value.first().manga
|
||||||
|
val source = entry.value.first().source
|
||||||
|
deleteChapters(entry.value.map { it.chapter }, manga, source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the directories of a list of downloaded chapters.
|
* Deletes the directories of a list of downloaded chapters.
|
||||||
*
|
*
|
||||||
|
@ -356,6 +356,15 @@ class DownloadController :
|
|||||||
val downloads = adapter.currentItems.mapNotNull { it?.download }
|
val downloads = adapter.currentItems.mapNotNull { it?.download }
|
||||||
presenter.reorder(downloads)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,4 +65,8 @@ class DownloadPresenter : BasePresenter<DownloadController>() {
|
|||||||
fun cancelDownload(download: Download) {
|
fun cancelDownload(download: Download) {
|
||||||
downloadManager.deletePendingDownload(download)
|
downloadManager.deletePendingDownload(download)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun cancelDownloads(downloads: List<Download>) {
|
||||||
|
downloadManager.deletePendingDownloads(*downloads.toTypedArray())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,4 +13,7 @@
|
|||||||
android:id="@+id/cancel_download"
|
android:id="@+id/cancel_download"
|
||||||
android:title="@string/action_cancel" />
|
android:title="@string/action_cancel" />
|
||||||
|
|
||||||
|
<item android:id="@+id/cancel_series"
|
||||||
|
android:title="@string/cancel_all_for_series" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -102,6 +102,7 @@
|
|||||||
<string name="action_unpin">Unpin</string>
|
<string name="action_unpin">Unpin</string>
|
||||||
<string name="action_cancel">Cancel</string>
|
<string name="action_cancel">Cancel</string>
|
||||||
<string name="action_cancel_all">Cancel all</string>
|
<string name="action_cancel_all">Cancel all</string>
|
||||||
|
<string name="cancel_all_for_series">Cancel all for this series</string>
|
||||||
<string name="action_sort">Sort</string>
|
<string name="action_sort">Sort</string>
|
||||||
<string name="action_sort_descending">Descending</string>
|
<string name="action_sort_descending">Descending</string>
|
||||||
<string name="action_reorganize_by">Reorder</string>
|
<string name="action_reorganize_by">Reorder</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user