From 9d5f197997fb88baaf47426b809741d846214d31 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 7 Sep 2022 10:04:55 +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 --- .../app/ui/book/read/page/ContentTextView.kt | 21 ++++++++++++++++++- .../legado/app/ui/book/read/page/PageView.kt | 2 +- .../legado/app/ui/book/read/page/ReadView.kt | 4 +++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index b4f9dc173..e11d5c335 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -28,7 +28,7 @@ import io.legado.app.utils.toastOnUi import kotlin.math.min /** - * 阅读内容界面 + * 阅读内容视图 */ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, attrs) { var selectAble = context.getPrefBoolean(PreferKey.textSelectAble, true) @@ -65,12 +65,18 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at callBack = activity as CallBack } + /** + * 设置内容 + */ fun setContent(textPage: TextPage) { this.textPage = textPage imagePaint.isAntiAlias = AppConfig.useAntiAlias invalidate() } + /** + * 更新绘制区域 + */ fun upVisibleRect() { visibleRect.set( ChapterProvider.paddingLeft.toFloat(), @@ -121,6 +127,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at } } + /** + * 绘制页面 + */ private fun draw( canvas: Canvas, textPage: TextPage, @@ -259,6 +268,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at invalidate() } + /** + * 重置滚动位置 + */ fun resetPageOffset() { pageOffset = 0 } @@ -288,6 +300,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at * @return true:已处理, false:未处理 */ fun click(x: Float, y: Float): Boolean { + touch(x, y) { _, relativePos, textPage, lineIndex, textLine, charIndex, textChar -> + + } return false } @@ -342,6 +357,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at } } + /** + * 触碰位置信息 + * @param touched 回调 + */ private fun touch( x: Float, y: Float, diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 286dc8aa0..3637438f1 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -24,7 +24,7 @@ import splitties.views.backgroundColor import java.util.* /** - * 阅读界面 + * 页面视图 */ class PageView(context: Context) : FrameLayout(context) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt index b4fef733a..eafd9a7bb 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt @@ -32,7 +32,9 @@ import java.text.BreakIterator import java.util.* import kotlin.math.abs - +/** + * 阅读视图 + */ class ReadView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), DataSource {