From 7dc70c9eab2b9c991a807c3402b6976df9873314 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 7 Nov 2020 19:22:01 -0500 Subject: [PATCH] Add 1.x page model converters --- app/src/main/java/eu/kanade/tachiyomi/source/Source.kt | 4 ++-- .../main/java/eu/kanade/tachiyomi/source/model/Page.kt | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt b/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt index c7896e88a7..3b7a8cd891 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt @@ -7,7 +7,7 @@ import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.toChapterInfo import eu.kanade.tachiyomi.source.model.toMangaInfo -import eu.kanade.tachiyomi.source.model.toPageInfo +import eu.kanade.tachiyomi.source.model.toPageUrl import eu.kanade.tachiyomi.source.model.toSChapter import eu.kanade.tachiyomi.source.model.toSManga import eu.kanade.tachiyomi.util.lang.awaitSingle @@ -80,7 +80,7 @@ interface Source : tachiyomi.source.Source { */ override suspend fun getPageList(chapter: ChapterInfo): List { return fetchPageList(chapter.toSChapter()).awaitSingle() - .map { it.toPageInfo() } + .map { it.toPageUrl() } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt b/app/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt index c57388a91b..e7e2028d8a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt @@ -63,8 +63,15 @@ open class Page( } } -fun Page.toPageInfo(): PageUrl { +fun Page.toPageUrl(): PageUrl { return PageUrl( url = this.imageUrl ?: this.url ) } + +fun PageUrl.toPage(index: Int): Page { + return Page( + index = index, + imageUrl = this.url + ) +}