diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index 646e87228..10b0ea74d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -6,7 +6,6 @@ import eu.kanade.domain.chapter.model.Chapter import eu.kanade.domain.download.service.DownloadPreferences import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.database.models.toDomainChapter import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.download.model.DownloadQueue import eu.kanade.tachiyomi.source.Source @@ -221,7 +220,7 @@ class DownloadManager( } fun cancelQueuedDownloads(downloads: List) { - removeFromDownloadQueue(downloads.mapNotNull { it.chapter.toDomainChapter() }) + removeFromDownloadQueue(downloads.map { it.chapter }) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt index a275a1d4f..4d8bf57ca 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.data.download import android.content.Context import androidx.core.content.edit import eu.kanade.domain.chapter.interactor.GetChapter -import eu.kanade.domain.chapter.model.toDbChapter import eu.kanade.domain.manga.interactor.GetManga import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.data.download.model.Download @@ -78,7 +77,7 @@ class DownloadStore( * @param download the download. */ private fun getKey(download: Download): String { - return download.chapter.id!!.toString() + return download.chapter.id.toString() } /** @@ -98,7 +97,7 @@ class DownloadStore( runBlocking { getManga.await(mangaId) } } ?: continue val source = sourceManager.get(manga.source) as? HttpSource ?: continue - val chapter = runBlocking { getChapter.await(chapterId) }?.toDbChapter() ?: continue + val chapter = runBlocking { getChapter.await(chapterId) } ?: continue downloads.add(Download(source, manga, chapter)) } } @@ -114,7 +113,7 @@ class DownloadStore( * @param download the download to serialize. */ private fun serialize(download: Download): String { - val obj = DownloadObject(download.manga.id, download.chapter.id!!, counter++) + val obj = DownloadObject(download.manga.id, download.chapter.id, counter++) return json.encodeToString(obj) } 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 620798936..3e591379f 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 @@ -4,7 +4,6 @@ import android.content.Context import com.hippo.unifile.UniFile import com.jakewharton.rxrelay.PublishRelay import eu.kanade.domain.chapter.model.Chapter -import eu.kanade.domain.chapter.model.toDbChapter import eu.kanade.domain.download.service.DownloadPreferences import eu.kanade.domain.manga.model.COMIC_INFO_FILE import eu.kanade.domain.manga.model.ComicInfo @@ -267,7 +266,7 @@ class Downloader( // Filter out those already enqueued. .filter { chapter -> queue.none { it.chapter.id == chapter.id } } // Create a download for each one. - .map { Download(source, manga, it.toDbChapter()) } + .map { Download(source, manga, it) } if (chaptersToQueue.isNotEmpty()) { queue.addAll(chaptersToQueue) @@ -322,7 +321,7 @@ class Downloader( val pageListObservable = if (download.pages == null) { // Pull page list from network and add them to download object - download.source.fetchPageList(download.chapter) + download.source.fetchPageList(download.chapter.toSChapter()) .map { pages -> if (pages.isEmpty()) { throw Exception(context.getString(R.string.page_list_empty_error)) 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 d632bafc4..7dff294b9 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 @@ -1,10 +1,9 @@ package eu.kanade.tachiyomi.data.download.model import eu.kanade.domain.chapter.interactor.GetChapter -import eu.kanade.domain.chapter.model.toDbChapter +import eu.kanade.domain.chapter.model.Chapter import eu.kanade.domain.manga.interactor.GetManga import eu.kanade.domain.manga.model.Manga -import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.online.HttpSource @@ -75,7 +74,7 @@ data class Download( val manga = getManga.await(chapter.mangaId) ?: return null val source = sourceManager.get(manga.source) as? HttpSource ?: return null - return Download(source, manga, chapter.toDbChapter()) + return Download(source, manga, chapter) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadItem.kt index 783ec061f..6dd4f9b25 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadItem.kt @@ -63,6 +63,6 @@ class DownloadItem( } override fun hashCode(): Int { - return download.chapter.id!!.toInt() + return download.chapter.id.toInt() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt index 0f68c1fe3..37584ee4e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt @@ -135,7 +135,7 @@ object DownloadQueueScreen : Screen { text = { Text(text = stringResource(R.string.action_newest)) }, onClick = { screenModel.reorderQueue( - { it.download.chapter.date_upload }, + { it.download.chapter.dateUpload }, true, ) closeMenu() @@ -145,7 +145,7 @@ object DownloadQueueScreen : Screen { text = { Text(text = stringResource(R.string.action_oldest)) }, onClick = { screenModel.reorderQueue( - { it.download.chapter.date_upload }, + { it.download.chapter.dateUpload }, false, ) closeMenu() @@ -160,7 +160,7 @@ object DownloadQueueScreen : Screen { text = { Text(text = stringResource(R.string.action_asc)) }, onClick = { screenModel.reorderQueue( - { it.download.chapter.chapter_number }, + { it.download.chapter.chapterNumber }, false, ) closeMenu() @@ -170,7 +170,7 @@ object DownloadQueueScreen : Screen { text = { Text(text = stringResource(R.string.action_desc)) }, onClick = { screenModel.reorderQueue( - { it.download.chapter.chapter_number }, + { it.download.chapter.chapterNumber }, true, ) closeMenu() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreenModel.kt index 17a1d1d63..750566943 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreenModel.kt @@ -260,6 +260,6 @@ class DownloadQueueScreenModel( * @return the holder of the download or null if it's not bound. */ private fun getHolder(download: Download): DownloadHolder? { - return controllerBinding.recycler.findViewHolderForItemId(download.chapter.id!!) as? DownloadHolder + return controllerBinding.recycler.findViewHolderForItemId(download.chapter.id) as? DownloadHolder } }