From 3436708a94b68f1dd8b6cfff4c3d0e3bfeca91c2 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 25 Jul 2020 19:25:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E6=96=87=E8=A7=84=E5=88=99=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=9B=BE=E7=89=87=E6=A0=B7=E5=BC=8F=E8=A7=84=E5=88=99?= =?UTF-8?q?,=E5=8F=AF=E4=BB=A5=E8=AE=BE=E7=BD=AE=E4=B8=BAFULL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/help/ReadBook.kt | 26 ++++++++++-- .../read/page/provider/ChapterProvider.kt | 40 +++++++++++-------- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index a7691b5b9..7878cb1c2 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -313,7 +313,13 @@ object ReadBook { when (chapter.index) { durChapterIndex -> { curTextChapter = - ChapterProvider.getTextChapter(book, chapter, contents, chapterSize) + ChapterProvider.getTextChapter( + book, + chapter, + contents, + chapterSize, + imageStyle + ) if (upContent) callBack?.upContent(resetPageOffset = resetPageOffset) callBack?.upView() curPageChanged() @@ -322,12 +328,24 @@ object ReadBook { } durChapterIndex - 1 -> { prevTextChapter = - ChapterProvider.getTextChapter(book, chapter, contents, chapterSize) + ChapterProvider.getTextChapter( + book, + chapter, + contents, + chapterSize, + imageStyle + ) if (upContent) callBack?.upContent(-1, resetPageOffset) } durChapterIndex + 1 -> { nextTextChapter = - ChapterProvider.getTextChapter(book, chapter, contents, chapterSize) + ChapterProvider.getTextChapter( + book, + chapter, + contents, + chapterSize, + imageStyle + ) if (upContent) callBack?.upContent(1, resetPageOffset) } } @@ -338,6 +356,8 @@ object ReadBook { } } + private val imageStyle get() = webBook?.bookSource?.ruleContent?.imageStyle + fun saveRead() { Coroutine.async { book?.let { book -> diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index d74d3fefe..c5df5c9dd 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -51,7 +51,8 @@ object ChapterProvider { book: Book, bookChapter: BookChapter, contents: List, - chapterSize: Int + chapterSize: Int, + imageStyle: String? ): TextChapter { val textPages = arrayListOf() val pageLines = arrayListOf() @@ -69,7 +70,7 @@ object ChapterProvider { src?.let { durY = setTypeImage( - book, bookChapter, src, durY, textPages + book, bookChapter, src, durY, textPages, imageStyle ) } } else { @@ -116,25 +117,32 @@ object ChapterProvider { chapter: BookChapter, src: String, y: Float, - textPages: ArrayList + textPages: ArrayList, + imageStyle: String? ): Float { var durY = y ImageProvider.getImage(book, chapter.index, src)?.let { var height = it.height var width = it.width - if (it.width > visibleWidth) { - height = it.height * visibleWidth / it.width - width = - visibleWidth - } - if (height > visibleHeight) { - width = width * visibleHeight / height - height = - visibleHeight - } - if (durY + height > visibleHeight) { - textPages.add(TextPage()) - durY = 0f + when (imageStyle?.toUpperCase()) { + "FULL" -> { + width = visibleWidth + height = it.width / width * it.height + } + else -> { + if (it.width > visibleWidth) { + height = it.height * visibleWidth / it.width + width = visibleWidth + } + if (height > visibleHeight) { + width = width * visibleHeight / height + height = visibleHeight + } + if (durY + height > visibleHeight) { + textPages.add(TextPage()) + durY = 0f + } + } } val textLine = TextLine(isImage = true) textLine.lineTop = durY