From bd8e77b499c3902a800bde5de6ae9d55e8575b5f Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 22 Jul 2019 17:07:04 +0800 Subject: [PATCH] up --- .../app/model/webbook/BookChapterList.kt | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 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 61afa35c1..e965b9460 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 @@ -62,23 +62,33 @@ object BookChapterList { } if (reverse) chapterList.reverse() } else if (chapterData.nextUrl.size > 1) { + val chapterDataList = arrayListOf>() for (item in chapterData.nextUrl) { if (!nextUrlList.contains(item)) { + val data = ChapterData(nextUrl = item) + chapterDataList.add(data) + } + } + for (item in chapterDataList) { + if (!nextUrlList.contains(item.nextUrl)) { withContext(coroutineScope.coroutineContext) { - val nextResponse = AnalyzeUrl(ruleUrl = item, book = book).getResponseAsync().await() + val nextResponse = AnalyzeUrl(ruleUrl = item.nextUrl, book = book).getResponseAsync().await() val nextChapterData = analyzeChapterList( nextResponse.body() ?: "", - item, + item.nextUrl, tocRule, listRule, book ) - nextChapterData.chapterList?.let { - chapterList.addAll(it) - } + item.chapterList = nextChapterData.chapterList } } } + for (item in chapterDataList) { + item.chapterList?.let { + chapterList.addAll(it) + } + } if (reverse) chapterList.reverse() } return chapterList @@ -99,7 +109,7 @@ object BookChapterList { analyzeRule.getStringList(tocRule.nextTocUrl ?: "", true)?.let { nextUrlList.addAll(it) } - val elements = analyzeRule.getElements(tocRule.chapterList ?: "") + val elements = analyzeRule.getElements(listRule) if (elements.isNotEmpty()) { val nameRule = analyzeRule.splitSourceRule(tocRule.chapterName ?: "") val urlRule = analyzeRule.splitSourceRule(tocRule.chapterUrl ?: "")