From 3aa6c3f9453a1c22ce7056321d54237d94642928 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 24 Jul 2019 13:08:51 +0800 Subject: [PATCH] up --- .../io/legado/app/model/webbook/BookChapterList.kt | 6 +----- .../java/io/legado/app/model/webbook/BookContent.kt | 12 +++++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt b/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt index cbbb459a7..c5d21d264 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt @@ -50,11 +50,7 @@ object BookChapterList { AnalyzeUrl(ruleUrl = nextUrl, book = book).getResponse().execute() .body()?.let { nextBody -> chapterData = analyzeChapterList(nextBody, nextUrl, tocRule, listRule, book) - nextUrl = if (chapterData.nextUrl.isEmpty()) { - "" - } else { - chapterData.nextUrl[0] - } + nextUrl = if (chapterData.nextUrl.isNotEmpty()) chapterData.nextUrl[0] else "" chapterData.chapterList?.let { chapterList.addAll(it) } 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 f6b5a28f5..ce9f76b69 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 @@ -31,27 +31,29 @@ object BookContent { baseUrl ) ) + val content = StringBuilder() val nextUrlList = arrayListOf(baseUrl) val contentRule = bookSource.getContentRule() var contentData = analyzeContent(body, contentRule, book, baseUrl) - var content = contentData.content + content.append(contentData.content) if (contentData.nextUrl.size == 1) { var nextUrl = contentData.nextUrl[0] while (nextUrl.isNotEmpty() && !nextUrlList.contains(nextUrl)) { nextUrlList.add(nextUrl) AnalyzeUrl(ruleUrl = nextUrl, book = book).getResponse().execute() .body()?.let { nextBody -> - analyzeContent(nextBody, contentRule, book, baseUrl) - + contentData = analyzeContent(nextBody, contentRule, book, baseUrl) + nextUrl = if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else "" + content.append(contentData.content) } } } else if (contentData.nextUrl.size > 1) { } - return content + return content.toString() } - fun analyzeContent( + private fun analyzeContent( body: String, contentRule: ContentRule, book: Book,