mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-27 03:18:25 +01:00
More domain model usage
This commit is contained in:
parent
3791d82540
commit
a3378e6080
@ -7,7 +7,6 @@ import eu.kanade.domain.chapter.model.toDbChapter
|
|||||||
import eu.kanade.domain.chapter.repository.ChapterRepository
|
import eu.kanade.domain.chapter.repository.ChapterRepository
|
||||||
import eu.kanade.domain.manga.interactor.UpdateManga
|
import eu.kanade.domain.manga.interactor.UpdateManga
|
||||||
import eu.kanade.domain.manga.model.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
@ -97,7 +96,7 @@ class SyncChaptersWithSource(
|
|||||||
} else {
|
} else {
|
||||||
if (shouldUpdateDbChapter.await(dbChapter, chapter)) {
|
if (shouldUpdateDbChapter.await(dbChapter, chapter)) {
|
||||||
if (dbChapter.name != chapter.name && downloadManager.isChapterDownloaded(dbChapter.name, dbChapter.scanlator, manga.title, manga.source)) {
|
if (dbChapter.name != chapter.name && downloadManager.isChapterDownloaded(dbChapter.name, dbChapter.scanlator, manga.title, manga.source)) {
|
||||||
downloadManager.renameChapter(source, manga.toDbManga(), dbChapter.toDbChapter(), chapter.toDbChapter())
|
downloadManager.renameChapter(source, manga, dbChapter.toDbChapter(), chapter.toDbChapter())
|
||||||
}
|
}
|
||||||
var toChangeChapter = dbChapter.copy(
|
var toChangeChapter = dbChapter.copy(
|
||||||
name = chapter.name,
|
name = chapter.name,
|
||||||
|
@ -42,22 +42,20 @@ data class Chapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun create(): Chapter {
|
fun create() = Chapter(
|
||||||
return Chapter(
|
id = -1,
|
||||||
id = -1,
|
mangaId = -1,
|
||||||
mangaId = -1,
|
read = false,
|
||||||
read = false,
|
bookmark = false,
|
||||||
bookmark = false,
|
lastPageRead = 0,
|
||||||
lastPageRead = 0,
|
dateFetch = 0,
|
||||||
dateFetch = 0,
|
sourceOrder = 0,
|
||||||
sourceOrder = 0,
|
url = "",
|
||||||
url = "",
|
name = "",
|
||||||
name = "",
|
dateUpload = -1,
|
||||||
dateUpload = -1,
|
chapterNumber = -1f,
|
||||||
chapterNumber = -1f,
|
scanlator = null,
|
||||||
scanlator = null,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,20 +33,6 @@ data class Manga(
|
|||||||
val initialized: Boolean,
|
val initialized: Boolean,
|
||||||
) : Serializable {
|
) : Serializable {
|
||||||
|
|
||||||
fun toSManga(): SManga {
|
|
||||||
return SManga.create().also {
|
|
||||||
it.url = url
|
|
||||||
it.title = title
|
|
||||||
it.artist = artist
|
|
||||||
it.author = author
|
|
||||||
it.description = description
|
|
||||||
it.genre = genre.orEmpty().joinToString()
|
|
||||||
it.status = status.toInt()
|
|
||||||
it.thumbnail_url = thumbnailUrl
|
|
||||||
it.initialized = initialized
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val sorting: Long
|
val sorting: Long
|
||||||
get() = chapterFlags and CHAPTER_SORTING_MASK
|
get() = chapterFlags and CHAPTER_SORTING_MASK
|
||||||
|
|
||||||
@ -100,6 +86,18 @@ data class Manga(
|
|||||||
return chapterFlags and CHAPTER_SORT_DIR_MASK == CHAPTER_SORT_DESC
|
return chapterFlags and CHAPTER_SORT_DIR_MASK == CHAPTER_SORT_DESC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun toSManga(): SManga = SManga.create().also {
|
||||||
|
it.url = url
|
||||||
|
it.title = title
|
||||||
|
it.artist = artist
|
||||||
|
it.author = author
|
||||||
|
it.description = description
|
||||||
|
it.genre = genre.orEmpty().joinToString()
|
||||||
|
it.status = status.toInt()
|
||||||
|
it.thumbnail_url = thumbnailUrl
|
||||||
|
it.initialized = initialized
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// Generic filter that does not filter anything
|
// Generic filter that does not filter anything
|
||||||
const val SHOW_ALL = 0x00000000L
|
const val SHOW_ALL = 0x00000000L
|
||||||
@ -128,6 +126,26 @@ data class Manga(
|
|||||||
const val CHAPTER_DISPLAY_NAME = 0x00000000L
|
const val CHAPTER_DISPLAY_NAME = 0x00000000L
|
||||||
const val CHAPTER_DISPLAY_NUMBER = 0x00100000L
|
const val CHAPTER_DISPLAY_NUMBER = 0x00100000L
|
||||||
const val CHAPTER_DISPLAY_MASK = 0x00100000L
|
const val CHAPTER_DISPLAY_MASK = 0x00100000L
|
||||||
|
|
||||||
|
fun create() = Manga(
|
||||||
|
id = -1L,
|
||||||
|
url = "",
|
||||||
|
title = "",
|
||||||
|
source = -1L,
|
||||||
|
favorite = false,
|
||||||
|
lastUpdate = -1L,
|
||||||
|
dateAdded = -1L,
|
||||||
|
viewerFlags = -1L,
|
||||||
|
chapterFlags = -1L,
|
||||||
|
coverLastModified = -1L,
|
||||||
|
artist = null,
|
||||||
|
author = null,
|
||||||
|
description = null,
|
||||||
|
genre = null,
|
||||||
|
status = 0L,
|
||||||
|
thumbnailUrl = null,
|
||||||
|
initialized = false,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ package eu.kanade.tachiyomi.data.download
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
@ -4,9 +4,9 @@ import android.content.Context
|
|||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import com.jakewharton.rxrelay.BehaviorRelay
|
import com.jakewharton.rxrelay.BehaviorRelay
|
||||||
import eu.kanade.domain.category.interactor.GetCategories
|
import eu.kanade.domain.category.interactor.GetCategories
|
||||||
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
|
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
@ -2,8 +2,8 @@ package eu.kanade.tachiyomi.data.download
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
@ -155,7 +155,7 @@ class DownloadPendingDeleter(context: Context) {
|
|||||||
* Returns a manga entry from a manga model.
|
* Returns a manga entry from a manga model.
|
||||||
*/
|
*/
|
||||||
private fun Manga.toEntry(): MangaEntry {
|
private fun Manga.toEntry(): MangaEntry {
|
||||||
return MangaEntry(id!!, url, title, source)
|
return MangaEntry(id, url, title, source)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,9 +169,12 @@ class DownloadPendingDeleter(context: Context) {
|
|||||||
* Returns a manga model from a manga entry.
|
* Returns a manga model from a manga entry.
|
||||||
*/
|
*/
|
||||||
private fun MangaEntry.toModel(): Manga {
|
private fun MangaEntry.toModel(): Manga {
|
||||||
return Manga.create(url, title, source).also {
|
return Manga.create().copy(
|
||||||
it.id = id
|
url = url,
|
||||||
}
|
title = title,
|
||||||
|
source = source,
|
||||||
|
id = id,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,9 +3,9 @@ package eu.kanade.tachiyomi.data.download
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||||
|
@ -5,8 +5,7 @@ import androidx.core.content.edit
|
|||||||
import eu.kanade.domain.chapter.interactor.GetChapter
|
import eu.kanade.domain.chapter.interactor.GetChapter
|
||||||
import eu.kanade.domain.chapter.model.toDbChapter
|
import eu.kanade.domain.chapter.model.toDbChapter
|
||||||
import eu.kanade.domain.manga.interactor.GetManga
|
import eu.kanade.domain.manga.interactor.GetManga
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
@ -96,7 +95,7 @@ class DownloadStore(
|
|||||||
val cachedManga = mutableMapOf<Long, Manga?>()
|
val cachedManga = mutableMapOf<Long, Manga?>()
|
||||||
for ((mangaId, chapterId) in objs) {
|
for ((mangaId, chapterId) in objs) {
|
||||||
val manga = cachedManga.getOrPut(mangaId) {
|
val manga = cachedManga.getOrPut(mangaId) {
|
||||||
runBlocking { getManga.await(mangaId)?.toDbManga() }
|
runBlocking { getManga.await(mangaId) }
|
||||||
} ?: continue
|
} ?: continue
|
||||||
val source = sourceManager.get(manga.source) as? HttpSource ?: continue
|
val source = sourceManager.get(manga.source) as? HttpSource ?: continue
|
||||||
val chapter = runBlocking { getChapter.await(chapterId) }?.toDbChapter() ?: continue
|
val chapter = runBlocking { getChapter.await(chapterId) }?.toDbChapter() ?: continue
|
||||||
|
@ -5,10 +5,10 @@ import android.webkit.MimeTypeMap
|
|||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import com.jakewharton.rxrelay.BehaviorRelay
|
import com.jakewharton.rxrelay.BehaviorRelay
|
||||||
import com.jakewharton.rxrelay.PublishRelay
|
import com.jakewharton.rxrelay.PublishRelay
|
||||||
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
|
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateNotifier
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateNotifier
|
||||||
|
@ -3,9 +3,8 @@ package eu.kanade.tachiyomi.data.download.model
|
|||||||
import eu.kanade.domain.chapter.interactor.GetChapter
|
import eu.kanade.domain.chapter.interactor.GetChapter
|
||||||
import eu.kanade.domain.chapter.model.toDbChapter
|
import eu.kanade.domain.chapter.model.toDbChapter
|
||||||
import eu.kanade.domain.manga.interactor.GetManga
|
import eu.kanade.domain.manga.interactor.GetManga
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
@ -76,7 +75,7 @@ data class Download(
|
|||||||
val manga = getManga.await(chapter.mangaId) ?: return null
|
val manga = getManga.await(chapter.mangaId) ?: return null
|
||||||
val source = sourceManager.get(manga.source) as? HttpSource ?: return null
|
val source = sourceManager.get(manga.source) as? HttpSource ?: return null
|
||||||
|
|
||||||
return Download(source, manga.toDbManga(), chapter.toDbChapter())
|
return Download(source, manga, chapter.toDbChapter())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package eu.kanade.tachiyomi.data.download.model
|
package eu.kanade.tachiyomi.data.download.model
|
||||||
|
|
||||||
import com.jakewharton.rxrelay.PublishRelay
|
import com.jakewharton.rxrelay.PublishRelay
|
||||||
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadStore
|
import eu.kanade.tachiyomi.data.download.DownloadStore
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
|
@ -416,7 +416,7 @@ class LibraryUpdateService(
|
|||||||
private fun downloadChapters(manga: Manga, chapters: List<Chapter>) {
|
private fun downloadChapters(manga: Manga, chapters: List<Chapter>) {
|
||||||
// We don't want to start downloading while the library is updating, because websites
|
// We don't want to start downloading while the library is updating, because websites
|
||||||
// may don't like it and they could ban the user.
|
// may don't like it and they could ban the user.
|
||||||
downloadManager.downloadChapters(manga, chapters, false)
|
downloadManager.downloadChapters(manga.toDomainManga()!!, chapters, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,6 @@ import eu.kanade.domain.chapter.model.toChapterUpdate
|
|||||||
import eu.kanade.domain.chapter.model.toDbChapter
|
import eu.kanade.domain.chapter.model.toDbChapter
|
||||||
import eu.kanade.domain.manga.interactor.GetManga
|
import eu.kanade.domain.manga.interactor.GetManga
|
||||||
import eu.kanade.domain.manga.model.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.backup.BackupRestoreService
|
import eu.kanade.tachiyomi.data.backup.BackupRestoreService
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
@ -252,7 +251,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
if (manga != null) {
|
if (manga != null) {
|
||||||
val source = sourceManager.get(manga.source)
|
val source = sourceManager.get(manga.source)
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
downloadManager.deleteChapters(listOf(it.toDbChapter()), manga.toDbManga(), source)
|
downloadManager.deleteChapters(listOf(it.toDbChapter()), manga, source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,7 +269,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
*/
|
*/
|
||||||
private fun downloadChapters(chapterUrls: Array<String>, mangaId: Long) {
|
private fun downloadChapters(chapterUrls: Array<String>, mangaId: Long) {
|
||||||
launchIO {
|
launchIO {
|
||||||
val manga = getManga.await(mangaId)?.toDbManga()
|
val manga = getManga.await(mangaId)
|
||||||
val chapters = chapterUrls.mapNotNull { getChapter.await(it, mangaId)?.toDbChapter() }
|
val chapters = chapterUrls.mapNotNull { getChapter.await(it, mangaId)?.toDbChapter() }
|
||||||
if (manga != null && chapters.isNotEmpty()) {
|
if (manga != null && chapters.isNotEmpty()) {
|
||||||
downloadManager.downloadChapters(manga, chapters)
|
downloadManager.downloadChapters(manga, chapters)
|
||||||
|
@ -17,7 +17,6 @@ import eu.kanade.domain.manga.interactor.UpdateManga
|
|||||||
import eu.kanade.domain.manga.model.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.domain.manga.model.MangaUpdate
|
import eu.kanade.domain.manga.model.MangaUpdate
|
||||||
import eu.kanade.domain.manga.model.isLocal
|
import eu.kanade.domain.manga.model.isLocal
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
|
||||||
import eu.kanade.domain.track.interactor.GetTracks
|
import eu.kanade.domain.track.interactor.GetTracks
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
||||||
@ -154,7 +153,7 @@ class LibraryPresenter(
|
|||||||
val isDownloaded = when {
|
val isDownloaded = when {
|
||||||
item.manga.toDomainManga()!!.isLocal() -> true
|
item.manga.toDomainManga()!!.isLocal() -> true
|
||||||
item.downloadCount != -1 -> item.downloadCount > 0
|
item.downloadCount != -1 -> item.downloadCount > 0
|
||||||
else -> downloadManager.getDownloadCount(item.manga) > 0
|
else -> downloadManager.getDownloadCount(item.manga.toDomainManga()!!) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return@downloaded if (downloadedOnly || filterDownloaded == State.INCLUDE.value) isDownloaded
|
return@downloaded if (downloadedOnly || filterDownloaded == State.INCLUDE.value) isDownloaded
|
||||||
@ -236,7 +235,7 @@ class LibraryPresenter(
|
|||||||
for ((_, itemList) in map) {
|
for ((_, itemList) in map) {
|
||||||
for (item in itemList) {
|
for (item in itemList) {
|
||||||
item.downloadCount = if (showDownloadBadges) {
|
item.downloadCount = if (showDownloadBadges) {
|
||||||
downloadManager.getDownloadCount(item.manga)
|
downloadManager.getDownloadCount(item.manga.toDomainManga()!!)
|
||||||
} else {
|
} else {
|
||||||
// Unset download count if not enabled
|
// Unset download count if not enabled
|
||||||
-1
|
-1
|
||||||
@ -521,7 +520,7 @@ class LibraryPresenter(
|
|||||||
.filter { !it.read }
|
.filter { !it.read }
|
||||||
.map { it.toDbChapter() }
|
.map { it.toDbChapter() }
|
||||||
|
|
||||||
downloadManager.downloadChapters(manga.toDbManga(), chapters)
|
downloadManager.downloadChapters(manga, chapters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,7 +554,7 @@ class LibraryPresenter(
|
|||||||
|
|
||||||
private fun deleteChapters(manga: Manga, chapters: List<Chapter>) {
|
private fun deleteChapters(manga: Manga, chapters: List<Chapter>) {
|
||||||
sourceManager.get(manga.source)?.let { source ->
|
sourceManager.get(manga.source)?.let { source ->
|
||||||
downloadManager.deleteChapters(chapters.map { it.toDbChapter() }, manga.toDbManga(), source)
|
downloadManager.deleteChapters(chapters.map { it.toDbChapter() }, manga, source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,7 +584,7 @@ class LibraryPresenter(
|
|||||||
mangaToDelete.forEach { manga ->
|
mangaToDelete.forEach { manga ->
|
||||||
val source = sourceManager.get(manga.source) as? HttpSource
|
val source = sourceManager.get(manga.source) as? HttpSource
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
downloadManager.deleteManga(manga, source)
|
downloadManager.deleteManga(manga.toDomainManga()!!, source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ class MangaPresenter(
|
|||||||
*/
|
*/
|
||||||
fun hasDownloads(): Boolean {
|
fun hasDownloads(): Boolean {
|
||||||
val manga = successState?.manga ?: return false
|
val manga = successState?.manga ?: return false
|
||||||
return downloadManager.getDownloadCount(manga.toDbManga()) > 0
|
return downloadManager.getDownloadCount(manga) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -313,7 +313,7 @@ class MangaPresenter(
|
|||||||
*/
|
*/
|
||||||
fun deleteDownloads() {
|
fun deleteDownloads() {
|
||||||
val state = successState ?: return
|
val state = successState ?: return
|
||||||
downloadManager.deleteManga(state.manga.toDbManga(), state.source)
|
downloadManager.deleteManga(state.manga, state.source)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -541,7 +541,7 @@ class MangaPresenter(
|
|||||||
*/
|
*/
|
||||||
fun downloadChapters(chapters: List<DomainChapter>) {
|
fun downloadChapters(chapters: List<DomainChapter>) {
|
||||||
val manga = successState?.manga ?: return
|
val manga = successState?.manga ?: return
|
||||||
downloadManager.downloadChapters(manga.toDbManga(), chapters.map { it.toDbChapter() })
|
downloadManager.downloadChapters(manga, chapters.map { it.toDbChapter() })
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -567,7 +567,7 @@ class MangaPresenter(
|
|||||||
try {
|
try {
|
||||||
updateSuccessState { successState ->
|
updateSuccessState { successState ->
|
||||||
val deletedIds = downloadManager
|
val deletedIds = downloadManager
|
||||||
.deleteChapters(chapters2, successState.manga.toDbManga(), successState.source)
|
.deleteChapters(chapters2, successState.manga, successState.source)
|
||||||
.map { it.id }
|
.map { it.id }
|
||||||
val deletedChapters = successState.chapters.filter { deletedIds.contains(it.chapter.id) }
|
val deletedChapters = successState.chapters.filter { deletedIds.contains(it.chapter.id) }
|
||||||
if (deletedChapters.isEmpty()) return@updateSuccessState successState
|
if (deletedChapters.isEmpty()) return@updateSuccessState successState
|
||||||
|
@ -804,7 +804,7 @@ class ReaderPresenter(
|
|||||||
val manga = manga ?: return
|
val manga = manga ?: return
|
||||||
|
|
||||||
launchIO {
|
launchIO {
|
||||||
downloadManager.enqueueDeleteChapters(listOf(chapter.chapter), manga)
|
downloadManager.enqueueDeleteChapters(listOf(chapter.chapter), manga.toDomainManga()!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import android.app.Application
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import eu.kanade.domain.manga.model.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
@ -46,7 +45,7 @@ class DownloadPageLoader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getPagesFromDirectory(): Observable<List<ReaderPage>> {
|
private fun getPagesFromDirectory(): Observable<List<ReaderPage>> {
|
||||||
return downloadManager.buildPageList(source, manga.toDbManga(), chapter.chapter)
|
return downloadManager.buildPageList(source, manga, chapter.chapter)
|
||||||
.map { pages ->
|
.map { pages ->
|
||||||
pages.map { page ->
|
pages.map { page ->
|
||||||
ReaderPage(page.index, page.url, page.imageUrl) {
|
ReaderPage(page.index, page.url, page.imageUrl) {
|
||||||
|
@ -8,7 +8,6 @@ import eu.kanade.domain.chapter.model.Chapter
|
|||||||
import eu.kanade.domain.chapter.model.ChapterUpdate
|
import eu.kanade.domain.chapter.model.ChapterUpdate
|
||||||
import eu.kanade.domain.chapter.model.toDbChapter
|
import eu.kanade.domain.chapter.model.toDbChapter
|
||||||
import eu.kanade.domain.manga.model.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
@ -219,7 +218,7 @@ class UpdatesPresenter : BasePresenter<UpdatesController>() {
|
|||||||
* @param items list of recent chapters seleted.
|
* @param items list of recent chapters seleted.
|
||||||
*/
|
*/
|
||||||
fun downloadChapters(items: List<UpdatesItem>) {
|
fun downloadChapters(items: List<UpdatesItem>) {
|
||||||
items.forEach { downloadManager.downloadChapters(it.manga.toDbManga(), listOf(it.chapter.toDbChapter())) }
|
items.forEach { downloadManager.downloadChapters(it.manga, listOf(it.chapter.toDbChapter())) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,7 +229,7 @@ class UpdatesPresenter : BasePresenter<UpdatesController>() {
|
|||||||
private fun deleteChaptersInternal(chapterItems: List<UpdatesItem>) {
|
private fun deleteChaptersInternal(chapterItems: List<UpdatesItem>) {
|
||||||
val itemsByManga = chapterItems.groupBy { it.manga.id }
|
val itemsByManga = chapterItems.groupBy { it.manga.id }
|
||||||
for ((_, items) in itemsByManga) {
|
for ((_, items) in itemsByManga) {
|
||||||
val manga = items.first().manga.toDbManga()
|
val manga = items.first().manga
|
||||||
val source = sourceManager.get(manga.source) ?: continue
|
val source = sourceManager.get(manga.source) ?: continue
|
||||||
val chapters = items.map { it.chapter.toDbChapter() }
|
val chapters = items.map { it.chapter.toDbChapter() }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user