From 6294c929826908b9d0f75a85e732b5f8da284725 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 22 Feb 2020 19:57:21 +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 --- app/src/main/java/io/legado/app/help/BookHelp.kt | 6 ++---- .../main/java/io/legado/app/model/webBook/BookContent.kt | 2 +- .../java/io/legado/app/ui/book/read/page/ChapterProvider.kt | 1 + .../java/io/legado/app/ui/book/read/page/ContentTextView.kt | 5 ++++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index e474bff96..a4227619b 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -247,7 +247,6 @@ object BookHelp { content: String, enableReplace: Boolean ): String { - var c = content synchronized(this) { if (enableReplace && (bookName != name || bookOrigin != origin)) { replaceRules = if (origin.isNullOrEmpty()) { @@ -257,6 +256,7 @@ object BookHelp { } } } + var c = content for (item in replaceRules) { item.pattern.let { if (it.isNotEmpty()) { @@ -268,9 +268,7 @@ object BookHelp { } } } - if (!content.substringBefore("\n").contains(title)) { - c = title + "\n" + c - } + c = "$title\n$c" when (AppConfig.chineseConverterType) { 1 -> c = ZhConvertBootstrap.newInstance().toSimple(c) 2 -> c = ZhConvertBootstrap.newInstance().toTraditional(c) diff --git a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt index b9455e6ff..47396ad9c 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt @@ -37,7 +37,7 @@ object BookContent { val nextUrlList = arrayListOf(baseUrl) val contentRule = bookSource.getContentRule() var contentData = analyzeContent(body, contentRule, book, bookChapter, bookSource, baseUrl) - content.append(contentData.content) + content.append(contentData.content.replace(bookChapter.title, "")) if (contentData.nextUrl.size == 1) { var nextUrl = contentData.nextUrl[0] val nextChapterUrl = if (!nextChapterUrlF.isNullOrEmpty()) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 33b58b530..db7ccc13d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -111,6 +111,7 @@ object ChapterProvider { durY = joinBody(text, durY, textPages, pageLines, pageLengths, stringBuilder) } } + textPages.last().text = stringBuilder.toString() if (pageLines.size < textPages.size) { pageLines.add(textPages.last().textLines.size) } 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 fe9bb85b6..059f0ad8c 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 @@ -16,7 +16,6 @@ import io.legado.app.utils.getPrefBoolean class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, attrs) { - private val maxScrollOffset = 100f private val selectedPaint by lazy { Paint().apply { color = context.getCompatColor(R.color.btn_bg_press_2) @@ -30,6 +29,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at private var selectLineEnd = 0 private var selectCharEnd = 0 private var textPage: TextPage? = null + //滚动参数 + private val maxScrollOffset = 100f + private val pageOffset = 0f + private val isLastPage = false init { activityCallBack = activity as CallBack