mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34: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.graphics.Canvas
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.VelocityTracker
|
import android.view.VelocityTracker
|
||||||
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.help.book.isImage
|
import io.legado.app.help.book.isImage
|
||||||
import io.legado.app.model.ReadBook
|
import io.legado.app.model.ReadBook
|
||||||
import io.legado.app.ui.book.read.page.ReadView
|
import io.legado.app.ui.book.read.page.ReadView
|
||||||
@ -132,11 +133,13 @@ class ScrollPageDelegate(readView: ReadView) : PageDelegate(readView) {
|
|||||||
*/
|
*/
|
||||||
private fun calcNextPageOffset(): Int {
|
private fun calcNextPageOffset(): Int {
|
||||||
val visibleHeight = ChapterProvider.visibleHeight
|
val visibleHeight = ChapterProvider.visibleHeight
|
||||||
if (ReadBook.book?.isImage == true) {
|
val book = ReadBook.book!!
|
||||||
|
if (book.isImage) {
|
||||||
return -visibleHeight
|
return -visibleHeight
|
||||||
}
|
}
|
||||||
val visiblePage = readView.getCurVisiblePage()
|
val visiblePage = readView.getCurVisiblePage()
|
||||||
if (visiblePage.isImageOrEmpty()) {
|
val isTextStyle = book.getImageStyle().equals(Book.imgStyleText, true)
|
||||||
|
if (!isTextStyle && visiblePage.hasImageOrEmpty()) {
|
||||||
return -visibleHeight
|
return -visibleHeight
|
||||||
}
|
}
|
||||||
val lastLineTop = visiblePage.lines.last().lineTop.toInt()
|
val lastLineTop = visiblePage.lines.last().lineTop.toInt()
|
||||||
@ -146,11 +149,13 @@ class ScrollPageDelegate(readView: ReadView) : PageDelegate(readView) {
|
|||||||
|
|
||||||
private fun calcPrevPageOffset(): Int {
|
private fun calcPrevPageOffset(): Int {
|
||||||
val visibleHeight = ChapterProvider.visibleHeight
|
val visibleHeight = ChapterProvider.visibleHeight
|
||||||
if (ReadBook.book?.isImage == true) {
|
val book = ReadBook.book!!
|
||||||
|
if (book.isImage) {
|
||||||
return visibleHeight
|
return visibleHeight
|
||||||
}
|
}
|
||||||
val visiblePage = readView.getCurVisiblePage()
|
val visiblePage = readView.getCurVisiblePage()
|
||||||
if (visiblePage.isImageOrEmpty()) {
|
val isTextStyle = book.getImageStyle().equals(Book.imgStyleText, true)
|
||||||
|
if (!isTextStyle && visiblePage.hasImageOrEmpty()) {
|
||||||
return visibleHeight
|
return visibleHeight
|
||||||
}
|
}
|
||||||
val firstLineBottom = visiblePage.lines.first().lineBottom.toInt()
|
val firstLineBottom = visiblePage.lines.first().lineBottom.toInt()
|
||||||
|
@ -233,7 +233,7 @@ data class TextPage(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isImageOrEmpty(): Boolean {
|
fun hasImageOrEmpty(): Boolean {
|
||||||
return textLines.all { it.isTitle || it.isImage }
|
return textLines.any { it.isImage }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user