From 309f0c53d2443b45a84fb5be622f5eba5623c798 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 8 Feb 2022 12:27:16 +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 --- .../io/legado/app/ui/book/info/BookInfoActivity.kt | 5 +++-- .../app/ui/book/info/edit/BookInfoEditActivity.kt | 2 +- .../legado/app/ui/book/read/config/TocRegexDialog.kt | 10 ++++++++-- app/src/main/res/menu/txt_toc_regex.xml | 6 ++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 981dbdebf..78563e242 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -105,8 +105,8 @@ class BookInfoActivity : binding.flAction.setBackgroundColor(bottomBackground) binding.tvShelf.setTextColor(getPrimaryTextColor(ColorUtils.isColorLight(bottomBackground))) binding.tvToc.text = getString(R.string.toc_s, getString(R.string.loading)) - viewModel.bookData.observe(this, { showBook(it) }) - viewModel.chapterListData.observe(this, { upLoading(false, it) }) + viewModel.bookData.observe(this) { showBook(it) } + viewModel.chapterListData.observe(this) { upLoading(false, it) } viewModel.initData(intent) initOnClick() } @@ -197,6 +197,7 @@ class BookInfoActivity : it.setLimitContentLength(!item.isChecked) viewModel.loadBookInfo(it, false) } + item.isChecked = !item.isChecked if (item.isChecked) longToastOnUi(R.string.need_more_time_load_content) } } diff --git a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt index 8f3725634..1e01e27fa 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt @@ -28,7 +28,7 @@ class BookInfoEditActivity : override val viewModel by viewModels() override fun onActivityCreated(savedInstanceState: Bundle?) { - viewModel.bookData.observe(this, { upView(it) }) + viewModel.bookData.observe(this) { upView(it) } if (viewModel.bookData.value == null) { intent.getStringExtra("bookUrl")?.let { viewModel.loadBook(it) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index cb29d093e..8bf8bceb3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -24,14 +24,13 @@ import io.legado.app.databinding.ItemTocRegexBinding import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.backgroundColor import io.legado.app.lib.theme.primaryColor +import io.legado.app.model.ReadBook import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.* import io.legado.app.utils.viewbindingdelegate.viewBinding import kotlinx.coroutines.Dispatchers.IO -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch -import java.util.* class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex), Toolbar.OnMenuItemClickListener { @@ -60,6 +59,8 @@ class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex), binding.toolBar.setTitle(R.string.txt_toc_regex) binding.toolBar.inflateMenu(R.menu.txt_toc_regex) binding.toolBar.menu.applyTint(requireContext()) + binding.toolBar.menu.findItem(R.id.menu_limit_content_length) + ?.isChecked = ReadBook.book?.getLimitContentLength() == true binding.toolBar.setOnMenuItemClickListener(this) initView() initData() @@ -114,6 +115,11 @@ class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex), R.id.menu_add -> editRule() R.id.menu_default -> viewModel.importDefault() R.id.menu_import -> showImportDialog() + R.id.menu_limit_content_length -> { + ReadBook.book?.setLimitContentLength(!item.isChecked) + item.isChecked = !item.isChecked + if (item.isChecked) context?.longToastOnUi(R.string.need_more_time_load_content) + } } return false } diff --git a/app/src/main/res/menu/txt_toc_regex.xml b/app/src/main/res/menu/txt_toc_regex.xml index 2eb4a2b4c..cf1a7751d 100644 --- a/app/src/main/res/menu/txt_toc_regex.xml +++ b/app/src/main/res/menu/txt_toc_regex.xml @@ -20,4 +20,10 @@ android:title="@string/import_replace_rule_on_line" app:showAsAction="never" /> + + \ No newline at end of file