mirror of
https://github.com/gedoor/legado.git
synced 2024-07-19 01:17:25 +08:00
优化
This commit is contained in:
parent
3a7e6d3911
commit
68ff06c390
@ -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()
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user