From b5457fe80c6cd37076fb663defd6db2e19f730f8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 24 Feb 2020 10:04:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/page/ContentTextView.kt | 11 +++++------ .../legado/app/ui/book/read/page/entities/TextPage.kt | 4 ++-- 2 files changed, 7 insertions(+), 8 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 404413fe0..5abb7175f 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 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at private var selectCharStart = 0 private var selectLineEnd = 0 private var selectCharEnd = 0 - private var textPage: TextPage = TextPage().textToLine() + private var textPage: TextPage = TextPage() //滚动参数 private val pageFactory: TextPageFactory get() = callBack.pageFactory private val maxScrollOffset = 100f @@ -49,11 +49,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { super.onSizeChanged(w, h, oldw, oldh) - ReadBookConfig.let { - ChapterProvider.viewWidth = w - ChapterProvider.viewHeight = h - ChapterProvider.upSize() - } + ChapterProvider.viewWidth = w + ChapterProvider.viewHeight = h + ChapterProvider.upSize() + textPage.format() } override fun onDraw(canvas: Canvas) { 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 c52a0834e..4e6089ddd 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 @@ -18,8 +18,8 @@ data class TextPage( ) { @Suppress("DEPRECATION") - fun textToLine(): TextPage { - if (textLines.isEmpty()) { + fun format(): TextPage { + if (textLines.isEmpty() && ChapterProvider.visibleWidth > 0) { val layout = StaticLayout( text, ChapterProvider.contentPaint, ChapterProvider.visibleWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, false