From 9242dfe476ae09c5c65bf0edd50e298c0d4bd75b Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Tue, 26 Mar 2024 21:44:59 +0800 Subject: [PATCH 1/2] =?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/ui/book/changesource/ChangeBookSourceDialog.kt | 3 ++- .../ui/book/changesource/ChangeBookSourceViewModel.kt | 6 ++++-- .../ui/book/changesource/ChangeChapterSourceDialog.kt | 9 +++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt index 9cec585ab254..6366e0dc9a01 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt @@ -283,8 +283,9 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_ } upGroupMenuName() lifecycleScope.launch(IO) { + viewModel.stopSearch() if (viewModel.refresh()) { - viewModel.startOrStopSearch() + viewModel.startSearch() } } } 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 acdaa7ee4cfb..7e7d35228a26 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 @@ -167,8 +167,10 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a fun startSearch() { execute { stopSearch() - appDb.searchBookDao.clear(name, author) - searchBooks.clear() + if (searchBooks.isNotEmpty()) { + appDb.searchBookDao.delete(*searchBooks.toTypedArray()) + searchBooks.clear() + } searchCallback?.upAdapter() bookSourceParts.clear() val searchGroup = AppConfig.searchGroup diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt index 33bbf82736ac..bb7215d31e28 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt @@ -45,6 +45,7 @@ import io.legado.app.utils.startActivity import io.legado.app.utils.toastOnUi import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.visible +import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.delay import kotlinx.coroutines.flow.conflate import kotlinx.coroutines.launch @@ -282,8 +283,12 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c } else { AppConfig.searchGroup = item.title.toString() } - viewModel.startOrStopSearch() - viewModel.refresh() + lifecycleScope.launch(IO) { + viewModel.stopSearch() + if (viewModel.refresh()) { + viewModel.startSearch() + } + } } } return false From 1e579d208bac88b46dc53ba64633b7d5bb8715d6 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Tue, 26 Mar 2024 22:28:49 +0800 Subject: [PATCH 2/2] =?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/utils/ChineseUtils.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/ChineseUtils.kt b/app/src/main/java/io/legado/app/utils/ChineseUtils.kt index ab297c907724..bd4efaa3909a 100644 --- a/app/src/main/java/io/legado/app/utils/ChineseUtils.kt +++ b/app/src/main/java/io/legado/app/utils/ChineseUtils.kt @@ -33,8 +33,9 @@ object ChineseUtils { val dict = DictionaryContainer.getInstance().getDictionary(TransType.TRADITIONAL_TO_SIMPLE) dict.run { remove("劈", "脊", "槃") - remove("支援", "沈默", "類比", "模擬", "划槳", "列根", "先進") - remove("路易斯", "非同步", "出租车", "周杰倫") + remove("支援", "沈默", "類比", "模擬", "划槳", "列根", "先進", "雪梨", "雪糕") + remove("零錢", "零钱", "離線", "碟片") + remove("路易斯", "非同步", "出租车", "周杰倫", "马铃薯", "馬鈴薯") } }