From db05963ed3724f7537196888f382f30e3e97e55e Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 8 Oct 2019 15:46:16 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/constant/AppConst.kt | 14 ++++++++++++++ .../app/ui/main/bookshelf/BookshelfFragment.kt | 4 ++-- .../app/ui/main/bookshelf/GroupManageDialog.kt | 13 ++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt index 99dcb17cb..6503839bc 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -4,6 +4,8 @@ import android.annotation.SuppressLint import io.legado.app.App import io.legado.app.R import io.legado.app.data.entities.BookGroup +import io.legado.app.utils.getPrefBoolean +import io.legado.app.utils.putPrefBoolean import java.text.SimpleDateFormat import javax.script.ScriptEngine import javax.script.ScriptEngineManager @@ -41,4 +43,16 @@ object AppConst { val bookGroupAll = BookGroup(-1, App.INSTANCE.getString(R.string.all)) val bookGroupLocal = BookGroup(-2, App.INSTANCE.getString(R.string.local)) val bookGroupAudio = BookGroup(-3, App.INSTANCE.getString(R.string.audio)) + + var bookGroupLocalShow: Boolean + get() = App.INSTANCE.getPrefBoolean("bookGroupLocal", false) + set(value) { + App.INSTANCE.putPrefBoolean("bookGroupLocal", value) + } + + var bookGroupAudioShow: Boolean + get() = App.INSTANCE.getPrefBoolean("bookGroupAudio", false) + set(value) { + App.INSTANCE.putPrefBoolean("bookGroupAudio", value) + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 797ef096d..9f97521b7 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -87,10 +87,10 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b synchronized(this) { bookGroups.clear() bookGroups.add(AppConst.bookGroupAll) - if (getPrefBoolean("bookGroupLocal", true)) { + if (AppConst.bookGroupLocalShow) { bookGroups.add(AppConst.bookGroupLocal) } - if (getPrefBoolean("bookGroupAudio", true)) { + if (AppConst.bookGroupAudioShow) { bookGroups.add(AppConst.bookGroupAudio) } bookGroups.addAll(it) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/GroupManageDialog.kt index f6151edaf..1f3423853 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/GroupManageDialog.kt @@ -20,13 +20,16 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter +import io.legado.app.constant.AppConst import io.legado.app.data.entities.BookGroup import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.noButton import io.legado.app.lib.dialogs.yesButton -import io.legado.app.utils.* +import io.legado.app.utils.applyTint +import io.legado.app.utils.getViewModel +import io.legado.app.utils.requestInputMethod import kotlinx.android.synthetic.main.dialog_edit_text.view.* import kotlinx.android.synthetic.main.dialog_recycler_view.* import kotlinx.android.synthetic.main.item_group_manage.view.* @@ -65,9 +68,9 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { tool_bar.menu.applyTint(requireContext(), false) tool_bar.setOnMenuItemClickListener(this) tool_bar.menu.findItem(R.id.menu_group_local) - .isChecked = getPrefBoolean("bookGroupLocal", true) + .isChecked = AppConst.bookGroupLocalShow tool_bar.menu.findItem(R.id.menu_group_audio) - .isChecked = getPrefBoolean("bookGroupAudio", true) + .isChecked = AppConst.bookGroupAudioShow adapter = GroupAdapter(requireContext()) recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration( @@ -88,12 +91,12 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { R.id.menu_add -> addGroup() R.id.menu_group_local -> { item.isChecked = !item.isChecked - putPrefBoolean("bookGroupLocal", item.isChecked) + AppConst.bookGroupLocalShow = item.isChecked callBack?.upGroup() } R.id.menu_group_audio -> { item.isChecked = !item.isChecked - putPrefBoolean("bookGroupAudio", item.isChecked) + AppConst.bookGroupAudioShow = item.isChecked callBack?.upGroup() } }