From 22f2ef18b18d11b37cc23917b0f20b9d1616f246 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sun, 9 May 2021 14:21:01 -0400 Subject: [PATCH] Using an enum to represent download states no need for the value int in upsteam, since enums can compare already Co-Authored-By: arkon <4098258+arkon@users.noreply.github.com> --- .../tachiyomi/data/download/Downloader.kt | 36 +++++++++---------- .../tachiyomi/data/download/model/Download.kt | 21 ++++++----- .../data/download/model/DownloadQueue.kt | 16 ++++----- .../tachiyomi/ui/download/DownloadButton.kt | 18 +++++----- .../ui/manga/MangaDetailsController.kt | 8 ++--- .../ui/manga/MangaDetailsPresenter.kt | 10 +++--- .../ui/manga/chapter/BaseChapterHolder.kt | 6 ++-- .../ui/manga/chapter/BaseChapterItem.kt | 6 ++-- .../ui/manga/chapter/ChapterHolder.kt | 4 +-- .../tachiyomi/ui/recents/RecentMangaHolder.kt | 6 ++-- .../tachiyomi/ui/recents/RecentsController.kt | 4 +-- .../tachiyomi/ui/recents/RecentsPresenter.kt | 6 ++-- 12 files changed, 73 insertions(+), 68 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 58c8f3d72a..18323fa328 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -111,8 +111,8 @@ class Downloader( notifier.paused = false if (!subscriptions.hasSubscriptions()) initializeSubscriptions() - val pending = queue.filter { it.status != Download.DOWNLOADED } - pending.forEach { if (it.status != Download.QUEUE) it.status = Download.QUEUE } + val pending = queue.filter { it.status != Download.State.DOWNLOADED } + pending.forEach { if (it.status != Download.State.QUEUE) it.status = Download.State.QUEUE } downloadsRelay.call(pending) return pending.isNotEmpty() @@ -124,8 +124,8 @@ class Downloader( fun stop(reason: String? = null) { destroySubscriptions() queue - .filter { it.status == Download.DOWNLOADING } - .forEach { it.status = Download.ERROR } + .filter { it.status == Download.State.DOWNLOADING } + .forEach { it.status = Download.State.ERROR } if (reason != null) { notifier.onWarning(reason) @@ -149,8 +149,8 @@ class Downloader( fun pause() { destroySubscriptions() queue - .filter { it.status == Download.DOWNLOADING } - .forEach { it.status = Download.QUEUE } + .filter { it.status == Download.State.DOWNLOADING } + .forEach { it.status = Download.State.QUEUE } notifier.paused = true } @@ -170,8 +170,8 @@ class Downloader( // Needed to update the chapter view if (isNotification) { queue - .filter { it.status == Download.QUEUE } - .forEach { it.status = Download.NOT_DOWNLOADED } + .filter { it.status == Download.State.QUEUE } + .forEach { it.status = Download.State.NOT_DOWNLOADED } } queue.clear() notifier.dismiss() @@ -185,8 +185,8 @@ class Downloader( fun clearQueue(manga: Manga, isNotification: Boolean = false) { // Needed to update the chapter view if (isNotification) { - queue.filter { it.status == Download.QUEUE && it.manga.id == manga.id } - .forEach { it.status = Download.NOT_DOWNLOADED } + queue.filter { it.status == Download.State.QUEUE && it.manga.id == manga.id } + .forEach { it.status = Download.State.NOT_DOWNLOADED } } queue.remove(manga) if (queue.isEmpty()) { @@ -294,7 +294,7 @@ class Downloader( val availSpace = DiskUtil.getAvailableStorageSpace(mangaDir) if (availSpace != -1L && availSpace < MIN_DISK_SPACE) { - download.status = Download.ERROR + download.status = Download.State.ERROR notifier.onError(context.getString(R.string.couldnt_download_low_space), download.chapter.name) return@defer Observable.just(download) } @@ -323,7 +323,7 @@ class Downloader( ?.forEach { it.delete() } download.downloadedImages = 0 - download.status = Download.DOWNLOADING + download.status = Download.State.DOWNLOADING } // Get all the URLs to the source images, fetch pages if necessary .flatMap { download.source.fetchAllImageUrlsFromPageList(it) } @@ -338,7 +338,7 @@ class Downloader( .doOnNext { ensureSuccessfulDownload(download, mangaDir, tmpDir, chapterDirname) } // If the page list threw, it will resume here .onErrorReturn { error -> - download.status = Download.ERROR + download.status = Download.State.ERROR notifier.onError(error.message, download.chapter.name) download } @@ -491,13 +491,13 @@ class Downloader( val downloadedImages = tmpDir.listFiles().orEmpty().filterNot { it.name!!.endsWith(".tmp") } download.status = if (downloadedImages.size == download.pages!!.size) { - Download.DOWNLOADED + Download.State.DOWNLOADED } else { - Download.ERROR + Download.State.ERROR } // Only rename the directory if it's downloaded. - if (download.status == Download.DOWNLOADED) { + if (download.status == Download.State.DOWNLOADED) { tmpDir.renameTo(dirname) cache.addChapter(dirname, mangaDir, download.manga) @@ -510,7 +510,7 @@ class Downloader( */ private fun completeDownload(download: Download) { // Delete successful downloads from queue - if (download.status == Download.DOWNLOADED) { + if (download.status == Download.State.DOWNLOADED) { // remove downloaded chapter from queue queue.remove(download) } @@ -527,7 +527,7 @@ class Downloader( * Returns true if all the queued downloads are in DOWNLOADED or ERROR state. */ private fun areAllDownloadsFinished(): Boolean { - return queue.none { it.status <= Download.DOWNLOADING } + return queue.none { it.status <= Download.State.DOWNLOADING } } companion object { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt index 5359b86f68..a720b411af 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt @@ -18,7 +18,7 @@ class Download(val source: HttpSource, val manga: Manga, val chapter: Chapter) { var downloadedImages: Int = 0 @Volatile @Transient - var status: Int = 0 + var status: State = State.default set(status) { field = status statusSubject?.onNext(this) @@ -49,12 +49,17 @@ class Download(val source: HttpSource, val manga: Manga, val chapter: Chapter) { statusCallback = f } - companion object { - const val CHECKED = -1 - const val NOT_DOWNLOADED = 0 - const val QUEUE = 1 - const val DOWNLOADING = 2 - const val DOWNLOADED = 3 - const val ERROR = 4 + enum class State { + CHECKED, + NOT_DOWNLOADED, + QUEUE, + DOWNLOADING, + DOWNLOADED, + ERROR + ; + + companion object { + val default = NOT_DOWNLOADED + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt index 31f3d1602f..d1a2228525 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt @@ -24,7 +24,7 @@ class DownloadQueue( downloads.forEach { download -> download.setStatusSubject(statusSubject) download.setStatusCallback(::setPagesFor) - download.status = Download.QUEUE + download.status = Download.State.QUEUE } queue.addAll(downloads) store.addAll(downloads) @@ -36,8 +36,8 @@ class DownloadQueue( store.remove(download) download.setStatusSubject(null) download.setStatusCallback(null) - if (download.status == Download.DOWNLOADING || download.status == Download.QUEUE) { - download.status = Download.NOT_DOWNLOADED + if (download.status == Download.State.DOWNLOADING || download.status == Download.State.QUEUE) { + download.status = Download.State.NOT_DOWNLOADED } downloadListeners.forEach { it.updateDownload(download) } if (removed) { @@ -65,8 +65,8 @@ class DownloadQueue( queue.forEach { download -> download.setStatusSubject(null) download.setStatusCallback(null) - if (download.status == Download.DOWNLOADING || download.status == Download.QUEUE) { - download.status = Download.NOT_DOWNLOADED + if (download.status == Download.State.DOWNLOADING || download.status == Download.State.QUEUE) { + download.status = Download.State.NOT_DOWNLOADED } downloadListeners.forEach { it.updateDownload(download) } } @@ -76,7 +76,7 @@ class DownloadQueue( } private fun setPagesFor(download: Download) { - if (download.status == Download.DOWNLOADING) { + if (download.status == Download.State.DOWNLOADING) { if (download.pages != null) { for (page in download.pages!!) page.setStatusCallback { @@ -84,9 +84,9 @@ class DownloadQueue( } } callListeners(download) - } else if (download.status == Download.DOWNLOADED || download.status == Download.ERROR) { + } else if (download.status == Download.State.DOWNLOADED || download.status == Download.State.ERROR) { setPagesSubject(download.pages, null) - if (download.status == Download.ERROR) { + if (download.status == Download.State.ERROR) { callListeners(download) } } else { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadButton.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadButton.kt index 0ed2894bc0..558817fc0d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadButton.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadButton.kt @@ -76,19 +76,19 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut binding = DownloadButtonBinding.bind(this) } - fun setDownloadStatus(state: Int, progress: Int = 0, animated: Boolean = false) { - if (state != Download.DOWNLOADING) { + fun setDownloadStatus(state: Download.State, progress: Int = 0, animated: Boolean = false) { + if (state != Download.State.DOWNLOADING) { iconAnimation?.cancel() binding.downloadIcon.alpha = 1f isAnimating = false } binding.downloadIcon.setImageDrawable( - if (state == Download.CHECKED) { + if (state == Download.State.CHECKED) { checkDrawable } else downloadDrawable ) when (state) { - Download.CHECKED -> { + Download.State.CHECKED -> { binding.downloadProgress.isVisible = false binding.downloadBorder.isVisible = true binding.downloadProgressIndeterminate.isVisible = false @@ -96,7 +96,7 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut binding.downloadBorder.drawable.setTint(activeColor) binding.downloadIcon.drawable.setTint(Color.WHITE) } - Download.NOT_DOWNLOADED -> { + Download.State.NOT_DOWNLOADED -> { binding.downloadBorder.isVisible = true binding.downloadProgress.isVisible = false binding.downloadProgressIndeterminate.isVisible = false @@ -104,14 +104,14 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut binding.downloadBorder.drawable.setTint(activeColor) binding.downloadIcon.drawable.setTint(activeColor) } - Download.QUEUE -> { + Download.State.QUEUE -> { binding.downloadBorder.isVisible = false binding.downloadProgress.isVisible = false binding.downloadProgressIndeterminate.isVisible = true binding.downloadProgress.isIndeterminate = true binding.downloadIcon.drawable.setTint(disabledColor) } - Download.DOWNLOADING -> { + Download.State.DOWNLOADING -> { binding.downloadBorder.isVisible = true binding.downloadProgress.isVisible = true binding.downloadProgressIndeterminate.isVisible = false @@ -131,7 +131,7 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut isAnimating = true } } - Download.DOWNLOADED -> { + Download.State.DOWNLOADED -> { binding.downloadProgress.isVisible = false binding.downloadBorder.isVisible = true binding.downloadProgressIndeterminate.isVisible = false @@ -159,7 +159,7 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut binding.downloadIcon.drawable.setTint(downloadedTextColor) } } - Download.ERROR -> { + Download.State.ERROR -> { binding.downloadProgress.isVisible = false binding.downloadBorder.isVisible = true binding.downloadProgressIndeterminate.isVisible = false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt index 1d0e873b77..8ba6f221cc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt @@ -629,7 +629,7 @@ class MangaDetailsController : (binding.recycler.findViewHolderForAdapterPosition(position) as? BaseFlexibleViewHolder) ?.toggleActivation() (binding.recycler.findViewHolderForAdapterPosition(position) as? ChapterHolder) - ?.notifyStatus(Download.CHECKED, false, 0) + ?.notifyStatus(Download.State.CHECKED, false, 0) startingRangeChapterPos = position actionMode?.invalidate() } else { @@ -1148,10 +1148,10 @@ class MangaDetailsController : onItemClick(null, position) return } - if (chapter.status != Download.NOT_DOWNLOADED && chapter.status != Download.ERROR) { + if (chapter.status != Download.State.NOT_DOWNLOADED && chapter.status != Download.State.ERROR) { presenter.deleteChapter(chapter) } else { - if (chapter.status == Download.ERROR) { + if (chapter.status == Download.State.ERROR) { DownloadService.start(view.context) } else { downloadChapters(listOf(chapter)) @@ -1352,7 +1352,7 @@ class MangaDetailsController : if (startingRangeChapterPos != null && rangeMode == RangeMode.Download) { val item = adapter?.getItem(startingRangeChapterPos!!) as? ChapterItem (binding.recycler.findViewHolderForAdapterPosition(startingRangeChapterPos!!) as? ChapterHolder)?.notifyStatus( - item?.status ?: Download.NOT_DOWNLOADED, + item?.status ?: Download.State.NOT_DOWNLOADED, false, 0 ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index 69a19c1c69..83af2c8074 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -162,10 +162,10 @@ class MangaDetailsPresenter( private fun setDownloadedChapters(chapters: List) { for (chapter in chapters) { if (downloadManager.isChapterDownloaded(chapter, manga)) { - chapter.status = Download.DOWNLOADED + chapter.status = Download.State.DOWNLOADED } else if (downloadManager.hasQueue()) { chapter.status = downloadManager.queue.find { it.chapter.id == chapter.id } - ?.status ?: 0 + ?.status ?: Download.State.default } } } @@ -267,7 +267,7 @@ class MangaDetailsPresenter( fun hasDownloads(): Boolean = allChapters.any { it.isDownloaded } fun getUnreadChaptersSorted() = - allChapters.filter { !it.read && it.status == Download.NOT_DOWNLOADED }.distinctBy { it.name } + allChapters.filter { !it.read && it.status == Download.State.NOT_DOWNLOADED }.distinctBy { it.name } .sortedByDescending { it.source_order } fun startDownloadingNow(chapter: Chapter) { @@ -289,7 +289,7 @@ class MangaDetailsPresenter( fun deleteChapter(chapter: ChapterItem) { downloadManager.deleteChapters(listOf(chapter), manga, source) this.chapters.find { it.id == chapter.id }?.apply { - status = Download.QUEUE + status = Download.State.QUEUE download = null } @@ -310,7 +310,7 @@ class MangaDetailsPresenter( } chapters.forEach { chapter -> this.chapters.find { it.id == chapter.id }?.apply { - status = Download.QUEUE + status = Download.State.QUEUE download = null } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterHolder.kt index 125738b12e..20bd852cb2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterHolder.kt @@ -19,7 +19,7 @@ open class BaseChapterHolder( val chapter = adapter.getItem(flexibleAdapterPosition) as? BaseChapterItem<*, *> ?: return val downloadButton = itemView.findViewById(R.id.download_button) ?: return - if (chapter.status == Download.NOT_DOWNLOADED || chapter.status == Download.ERROR) { + if (chapter.status == Download.State.NOT_DOWNLOADED || chapter.status == Download.State.ERROR) { adapter.baseDelegate.downloadChapter(flexibleAdapterPosition) } else { downloadButton.post { @@ -29,10 +29,10 @@ open class BaseChapterHolder( // Inflate our menu resource into the PopupMenu's Menu popup.menuInflater.inflate(R.menu.chapter_download, popup.menu) - popup.menu.findItem(R.id.action_start).isVisible = chapter.status == Download.QUEUE + popup.menu.findItem(R.id.action_start).isVisible = chapter.status == Download.State.QUEUE // Hide download and show delete if the chapter is downloaded - if (chapter.status != Download.DOWNLOADED) popup.menu.findItem(R.id.action_delete).title = downloadButton.context.getString( + if (chapter.status != Download.State.DOWNLOADED) popup.menu.findItem(R.id.action_delete).title = downloadButton.context.getString( R.string.cancel ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterItem.kt index 05c0bb68ff..29e6e9e766 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterItem.kt @@ -14,7 +14,7 @@ abstract class BaseChapterItem> AbstractSectionableItem(header), Chapter by chapter { - private var _status: Int = 0 + private var _status: Download.State = Download.State.default val progress: Int get() { @@ -22,14 +22,14 @@ abstract class BaseChapterItem> return pages.map(Page::progress).average().toInt() } - var status: Int + var status: Download.State get() = download?.status ?: _status set(value) { _status = value } @Transient var download: Download? = null val isDownloaded: Boolean - get() = status == Download.DOWNLOADED + get() = status == Download.State.DOWNLOADED override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt index c3eb50897d..ce3e08b6be 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt @@ -91,7 +91,7 @@ class ChapterHolder( binding.chapterScanlator.text = statuses.joinToString(" • ") val status = when { - adapter.isSelected(flexibleAdapterPosition) -> Download.CHECKED + adapter.isSelected(flexibleAdapterPosition) -> Download.State.CHECKED else -> item.status } @@ -149,7 +149,7 @@ class ChapterHolder( if (binding.frontView.translationX != 0f) itemView.post { adapter.notifyItemChanged(flexibleAdapterPosition) } } - fun notifyStatus(status: Int, locked: Boolean, progress: Int, animated: Boolean = false) = with(binding.downloadButton.downloadButton) { + fun notifyStatus(status: Download.State, locked: Boolean, progress: Int, animated: Boolean = false) = with(binding.downloadButton.downloadButton) { if (locked) { isVisible = false return diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt index eb609e1cac..be90ccc149 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt @@ -142,7 +142,7 @@ class RecentMangaHolder( } if (!item.mch.manga.isLocal()) { notifyStatus( - if (adapter.isSelected(flexibleAdapterPosition)) Download.CHECKED else item.status, + if (adapter.isSelected(flexibleAdapterPosition)) Download.State.CHECKED else item.status, item.progress, item.chapter.read ) @@ -160,7 +160,7 @@ class RecentMangaHolder( return item.mch.history.id != null } - fun notifyStatus(status: Int, progress: Int, isRead: Boolean, animated: Boolean = false) { + fun notifyStatus(status: Download.State, progress: Int, isRead: Boolean, animated: Boolean = false) { binding.downloadButton.downloadButton.setDownloadStatus(status, progress, animated) val isChapterRead = if (adapter.showDownloads == RecentMangaAdapter.ShowRecentsDLs.UnreadOrDownloaded) isRead else false @@ -168,7 +168,7 @@ class RecentMangaHolder( when (adapter.showDownloads) { RecentMangaAdapter.ShowRecentsDLs.UnreadOrDownloaded, RecentMangaAdapter.ShowRecentsDLs.OnlyDownloaded -> - status !in Download.CHECKED..Download.NOT_DOWNLOADED || !isChapterRead + status !in Download.State.CHECKED..Download.State.NOT_DOWNLOADED || !isChapterRead else -> binding.downloadButton.downloadButton.isVisible } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index d93472bc3c..d7d51fe93b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -523,10 +523,10 @@ class RecentsController(bundle: Bundle? = null) : val item = adapter.getItem(position) as? RecentMangaItem ?: return val chapter = item.chapter val manga = item.mch.manga - if (item.status != Download.NOT_DOWNLOADED && item.status != Download.ERROR) { + if (item.status != Download.State.NOT_DOWNLOADED && item.status != Download.State.ERROR) { presenter.deleteChapter(chapter, manga) } else { - if (item.status == Download.ERROR) DownloadService.start(view.context) + if (item.status == Download.State.ERROR) DownloadService.start(view.context) else presenter.downloadChapter(manga, chapter) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt index 33cd792ea4..fad75afe89 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt @@ -353,10 +353,10 @@ class RecentsPresenter( private fun setDownloadedChapters(chapters: List) { for (item in chapters.filter { it.chapter.id != null }) { if (downloadManager.isChapterDownloaded(item.chapter, item.mch.manga)) { - item.status = Download.DOWNLOADED + item.status = Download.State.DOWNLOADED } else if (downloadManager.hasQueue()) { item.status = downloadManager.queue.find { it.chapter.id == item.chapter.id } - ?.status ?: 0 + ?.status ?: Download.State.default } } } @@ -405,7 +405,7 @@ class RecentsPresenter( if (update) { val item = recentItems.find { it.chapter.id == chapter.id } ?: return item.apply { - status = Download.NOT_DOWNLOADED + status = Download.State.NOT_DOWNLOADED download = null }