multi download

This commit is contained in:
Finnley Somdahl 2023-12-05 20:35:25 -06:00
parent 0d422a57e7
commit b8782b0507
5 changed files with 58 additions and 0 deletions

View file

@ -114,6 +114,30 @@ class MangaChapterAdapter(
}
}
fun downloadNextNChapters(n: Int) {
//find last viewed chapter
var lastViewedChapter = arr.indexOfFirst { MangaNameAdapter.findChapterNumber(it.number)?.toInt() == media.userProgress }
if (lastViewedChapter == -1) {
lastViewedChapter = 0
}
//download next n chapters
for (i in 1..n) {
if (lastViewedChapter + i < arr.size) {
val chapterNumber = arr[lastViewedChapter + i].number
if (activeDownloads.contains(chapterNumber)) {
//do nothing
continue
} else if (downloadedChapters.contains(chapterNumber)) {
//do nothing
continue
} else {
fragment.onMangaChapterDownloadClick(chapterNumber)
startDownload(chapterNumber)
}
}
}
}
inner class ChapterListViewHolder(val binding: ItemChapterListBinding) :
RecyclerView.ViewHolder(binding.root) {
private val activeCoroutines = mutableSetOf<String>()