From 9ea725b2ca003a066bbe62420f702bf5889cabc2 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 8 Sep 2021 14:34:39 +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/src/main/java/io/legado/app/help/ContentProcessor.kt | 5 ++++- .../java/io/legado/app/ui/book/cache/CacheViewModel.kt | 9 +++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ContentProcessor.kt b/app/src/main/java/io/legado/app/help/ContentProcessor.kt index 7c973633e..71311086d 100644 --- a/app/src/main/java/io/legado/app/help/ContentProcessor.kt +++ b/app/src/main/java/io/legado/app/help/ContentProcessor.kt @@ -56,6 +56,7 @@ class ContentProcessor private constructor( title: String, //已经经过简繁转换 content: String, isRead: Boolean = true, + includeTitle: Boolean = true, useReplace: Boolean = book.getUseReplaceRule() ): List { var content1 = content @@ -91,7 +92,9 @@ class ContentProcessor private constructor( content1.split("\n").forEach { str -> val paragraph = str.replace("^[\\n\\r]+".toRegex(), "").trim() if (contents.isEmpty()) { - contents.add(title) + if (includeTitle) { + contents.add(title) + } if (paragraph != title && paragraph.isNotEmpty()) { contents.add("${ReadBookConfig.paragraphIndent}$paragraph") } diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt index 966eb451d..206baf27a 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt @@ -139,18 +139,15 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { ) appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter -> BookHelp.getContent(book, chapter).let { content -> - var content1 = contentProcessor + val content1 = contentProcessor .getContent( book, chapter.title.replace("\\r?\\n".toRegex(), " "), content ?: "null", false, + !AppConfig.exportNoChapterName, useReplace - ) - .joinToString("\n") - if(AppConfig.exportNoChapterName){ - content1 = content.toString() - } + ).joinToString("\n") append.invoke("\n\n$content1") } }