From 7ae3838a01fd0c599775f1f66700a9bbb7292d17 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 7 Apr 2022 15:14:44 +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 --- .../main/java/io/legado/app/help/config/AppConfig.kt | 12 ++++++++++-- .../ui/book/changesource/ChangeBookSourceDialog.kt | 9 ++++----- .../book/changesource/ChangeBookSourceViewModel.kt | 5 ++--- .../book/changesource/ChangeChapterSourceDialog.kt | 9 ++++----- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt index a851ce134..d9a045a2a 100644 --- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt @@ -276,9 +276,17 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { val autoChangeSource: Boolean get() = appCtx.getPrefBoolean(PreferKey.autoChangeSource, true) - val changeSourceLoadInfo get() = appCtx.getPrefBoolean(PreferKey.changeSourceLoadInfo) + var changeSourceLoadInfo: Boolean + get() = appCtx.getPrefBoolean(PreferKey.changeSourceLoadInfo) + set(value) { + appCtx.putPrefBoolean(PreferKey.changeSourceLoadInfo, value) + } - val changeSourceLoadToc get() = appCtx.getPrefBoolean(PreferKey.changeSourceLoadToc) + var changeSourceLoadToc: Boolean + get() = appCtx.getPrefBoolean(PreferKey.changeSourceLoadToc) + set(value) { + appCtx.putPrefBoolean(PreferKey.changeSourceLoadToc, value) + } val importKeepName get() = appCtx.getPrefBoolean(PreferKey.importKeepName) 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 1ebcb9e1b..e0b7be1aa 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 @@ -16,7 +16,6 @@ import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.constant.AppPattern import io.legado.app.constant.EventBus -import io.legado.app.constant.PreferKey import io.legado.app.data.appDb import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter @@ -207,12 +206,12 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_ item.isChecked = !item.isChecked viewModel.refresh() } - R.id.menu_load_toc -> { - putPrefBoolean(PreferKey.changeSourceLoadToc, !item.isChecked) + R.id.menu_load_info -> { + AppConfig.changeSourceLoadInfo = !item.isChecked item.isChecked = !item.isChecked } - R.id.menu_load_info -> { - putPrefBoolean(PreferKey.changeSourceLoadInfo, !item.isChecked) + R.id.menu_load_toc -> { + AppConfig.changeSourceLoadToc = !item.isChecked item.isChecked = !item.isChecked } R.id.menu_start_stop -> viewModel.startOrStopSearch() 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 f3f1985a7..337d6fae9 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 @@ -184,12 +184,11 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a } private suspend fun loadBookInfo(scope: CoroutineScope, source: BookSource, book: Book) { - val mBook = WebBook.getBookInfoAwait(scope, source, book) + WebBook.getBookInfoAwait(scope, source, book) if (context.getPrefBoolean(PreferKey.changeSourceLoadToc)) { - loadBookToc(scope, source, mBook) + loadBookToc(scope, source, book) } else { //从详情页里获取最新章节 - book.latestChapterTitle = mBook.latestChapterTitle val searchBook = book.toSearchBook() searchCallback?.searchSuccess(searchBook) } 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 21b61822e..fef913c26 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 @@ -16,7 +16,6 @@ import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.constant.AppPattern import io.legado.app.constant.EventBus -import io.legado.app.constant.PreferKey import io.legado.app.data.appDb import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter @@ -231,12 +230,12 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c item.isChecked = !item.isChecked viewModel.refresh() } - R.id.menu_load_toc -> { - putPrefBoolean(PreferKey.changeSourceLoadToc, !item.isChecked) + R.id.menu_load_info -> { + AppConfig.changeSourceLoadInfo = !item.isChecked item.isChecked = !item.isChecked } - R.id.menu_load_info -> { - putPrefBoolean(PreferKey.changeSourceLoadInfo, !item.isChecked) + R.id.menu_load_toc -> { + AppConfig.changeSourceLoadToc = !item.isChecked item.isChecked = !item.isChecked } R.id.menu_start_stop -> viewModel.startOrStopSearch()