From 68ff06c39034861a728dc27c4f958d83e7941f95 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Tue, 17 Jan 2023 09:59:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/read/page/delegate/ScrollPageDelegate.kt | 13 +++++++++---- .../app/ui/book/read/page/entities/TextPage.kt | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt index 1a8bd41a2..c3f9dc558 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt @@ -3,6 +3,7 @@ package io.legado.app.ui.book.read.page.delegate import android.graphics.Canvas import android.view.MotionEvent import android.view.VelocityTracker +import io.legado.app.data.entities.Book import io.legado.app.help.book.isImage import io.legado.app.model.ReadBook import io.legado.app.ui.book.read.page.ReadView @@ -132,11 +133,13 @@ class ScrollPageDelegate(readView: ReadView) : PageDelegate(readView) { */ private fun calcNextPageOffset(): Int { val visibleHeight = ChapterProvider.visibleHeight - if (ReadBook.book?.isImage == true) { + val book = ReadBook.book!! + if (book.isImage) { return -visibleHeight } val visiblePage = readView.getCurVisiblePage() - if (visiblePage.isImageOrEmpty()) { + val isTextStyle = book.getImageStyle().equals(Book.imgStyleText, true) + if (!isTextStyle && visiblePage.hasImageOrEmpty()) { return -visibleHeight } val lastLineTop = visiblePage.lines.last().lineTop.toInt() @@ -146,11 +149,13 @@ class ScrollPageDelegate(readView: ReadView) : PageDelegate(readView) { private fun calcPrevPageOffset(): Int { val visibleHeight = ChapterProvider.visibleHeight - if (ReadBook.book?.isImage == true) { + val book = ReadBook.book!! + if (book.isImage) { return visibleHeight } val visiblePage = readView.getCurVisiblePage() - if (visiblePage.isImageOrEmpty()) { + val isTextStyle = book.getImageStyle().equals(Book.imgStyleText, true) + if (!isTextStyle && visiblePage.hasImageOrEmpty()) { return visibleHeight } val firstLineBottom = visiblePage.lines.first().lineBottom.toInt() diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt index 76d9951b6..01cceab9d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt @@ -233,7 +233,7 @@ data class TextPage( return null } - fun isImageOrEmpty(): Boolean { - return textLines.all { it.isTitle || it.isImage } + fun hasImageOrEmpty(): Boolean { + return textLines.any { it.isImage } } }