From 314619e0146948da3a0a201eb3edbf2cf0131a33 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Thu, 12 Oct 2023 15:01:33 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../changesource/ChangeBookSourceViewModel.kt | 15 ++++++--------- .../legado/app/ui/book/read/ReadBookActivity.kt | 11 +++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceViewModel.kt index 363478363..21b38e701 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceViewModel.kt @@ -51,6 +51,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a private val searchBooks = Collections.synchronizedList(arrayListOf()) private val tocMap = ConcurrentHashMap>() private var searchCallback: SourceCallback? = null + private val emptyBookSource = BookSource() val bookMap = ConcurrentHashMap() val searchDataFlow = callbackFlow { @@ -113,7 +114,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a }.flowOn(IO) @Volatile - private var searchIndex = -1 + private var searchIndex = 0 override fun onCleared() { super.onCleared() @@ -137,7 +138,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a private fun initSearchPool() { searchPool = Executors .newFixedThreadPool(min(threadCount, AppConst.MAX_THREAD)).asCoroutineDispatcher() - searchIndex = -1 + searchIndex = 0 } fun refresh(): Boolean { @@ -180,13 +181,14 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a } private fun search() { - synchronized(this) { + val searchIndex = synchronized(this) { if (searchIndex >= bookSourceList.lastIndex) { return } searchIndex++ } val source = bookSourceList[searchIndex] + bookSourceList[searchIndex] = emptyBookSource val task = execute(context = searchPool!!, executeContext = searchPool!!) { val resultBooks = WebBook.searchBookAwait(source, name) resultBooks.forEach { searchBook -> @@ -197,15 +199,10 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a return@forEach } when { - searchBook.latestChapterTitle.isNullOrEmpty() && - (AppConfig.changeSourceLoadInfo || AppConfig.changeSourceLoadToc) -> { + AppConfig.changeSourceLoadInfo || AppConfig.changeSourceLoadToc || AppConfig.changeSourceLoadWordCount -> { loadBookInfo(source, searchBook.toBook()) } - AppConfig.changeSourceLoadWordCount -> { - loadBookToc(source, searchBook.toBook()) - } - else -> { searchCallback?.searchSuccess(searchBook) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 615973162..c8e6b744e 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -172,6 +172,7 @@ class ReadBookActivity : BaseReadBookActivity(), private val prevPageRunnable by lazy { Runnable { mouseWheelPage(PageDirection.PREV) } } private var bookChanged = false private var pageChanged = false + private var reloadContent = false //恢复跳转前进度对话框的交互结果 private var confirmRestoreProcess: Boolean? = null @@ -218,6 +219,10 @@ class ReadBookActivity : BaseReadBookActivity(), super.onPostCreate(savedInstanceState) viewModel.initData(intent) { upMenu() + if (reloadContent) { + reloadContent = false + ReadBook.loadContent(resetPageOffset = false) + } } } @@ -225,6 +230,10 @@ class ReadBookActivity : BaseReadBookActivity(), super.onNewIntent(intent) viewModel.initData(intent ?: return) { upMenu() + if (reloadContent) { + reloadContent = false + ReadBook.loadContent(resetPageOffset = false) + } } } @@ -1428,6 +1437,8 @@ class ReadBookActivity : BaseReadBookActivity(), if (it) { if (isInitFinish) { ReadBook.loadContent(resetPageOffset = false) + } else { + reloadContent = true } } else { readView.upContent(resetPageOffset = false) From 2ab772387ee00d0a84c432295c13aaabab641d74 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Fri, 13 Oct 2023 13:35:22 +0800 Subject: [PATCH 2/3] =?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/http/CookieStore.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/http/CookieStore.kt b/app/src/main/java/io/legado/app/help/http/CookieStore.kt index 5292298c3..20333f4ae 100644 --- a/app/src/main/java/io/legado/app/help/http/CookieStore.kt +++ b/app/src/main/java/io/legado/app/help/http/CookieStore.kt @@ -84,8 +84,8 @@ object CookieStore : CookieManagerInterface { } val pairArray = cookie.split(semicolonRegex).dropLastWhile { it.isEmpty() }.toTypedArray() for (pair in pairArray) { - val pairs = pair.split(equalsRegex).dropLastWhile { it.isEmpty() }.toTypedArray() - if (pairs.size == 1) { + val pairs = pair.split(equalsRegex, 2).dropLastWhile { it.isEmpty() }.toTypedArray() + if (pairs.size <= 1) { continue } val key = pairs[0].trim { it <= ' ' } From 00a87da36e2312ba6405234a55f36c079ff946c0 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Fri, 13 Oct 2023 13:44:49 +0800 Subject: [PATCH 3/3] =?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/model/localBook/LocalBook.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt index dd90b2c16..0720f5a1b 100644 --- a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt +++ b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt @@ -187,7 +187,6 @@ object LocalBook { name = nameAuthor.first, author = nameAuthor.second, originName = fileName, - coverUrl = getCoverPath(bookUrl), latestChapterTime = updateTime, order = appDb.bookDao.minOrder - 1 )