pull/37/head
kunfei 5 years ago
parent 2fbf6e94eb
commit db05963ed3
  1. 14
      app/src/main/java/io/legado/app/constant/AppConst.kt
  2. 4
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  3. 13
      app/src/main/java/io/legado/app/ui/main/bookshelf/GroupManageDialog.kt

@ -4,6 +4,8 @@ import android.annotation.SuppressLint
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.data.entities.BookGroup import io.legado.app.data.entities.BookGroup
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.putPrefBoolean
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import javax.script.ScriptEngine import javax.script.ScriptEngine
import javax.script.ScriptEngineManager import javax.script.ScriptEngineManager
@ -41,4 +43,16 @@ object AppConst {
val bookGroupAll = BookGroup(-1, App.INSTANCE.getString(R.string.all)) val bookGroupAll = BookGroup(-1, App.INSTANCE.getString(R.string.all))
val bookGroupLocal = BookGroup(-2, App.INSTANCE.getString(R.string.local)) val bookGroupLocal = BookGroup(-2, App.INSTANCE.getString(R.string.local))
val bookGroupAudio = BookGroup(-3, App.INSTANCE.getString(R.string.audio)) 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)
}
} }

@ -87,10 +87,10 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
synchronized(this) { synchronized(this) {
bookGroups.clear() bookGroups.clear()
bookGroups.add(AppConst.bookGroupAll) bookGroups.add(AppConst.bookGroupAll)
if (getPrefBoolean("bookGroupLocal", true)) { if (AppConst.bookGroupLocalShow) {
bookGroups.add(AppConst.bookGroupLocal) bookGroups.add(AppConst.bookGroupLocal)
} }
if (getPrefBoolean("bookGroupAudio", true)) { if (AppConst.bookGroupAudioShow) {
bookGroups.add(AppConst.bookGroupAudio) bookGroups.add(AppConst.bookGroupAudio)
} }
bookGroups.addAll(it) bookGroups.addAll(it)

@ -20,13 +20,16 @@ import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.constant.AppConst
import io.legado.app.data.entities.BookGroup import io.legado.app.data.entities.BookGroup
import io.legado.app.help.ItemTouchCallback import io.legado.app.help.ItemTouchCallback
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.customView
import io.legado.app.lib.dialogs.noButton import io.legado.app.lib.dialogs.noButton
import io.legado.app.lib.dialogs.yesButton 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_edit_text.view.*
import kotlinx.android.synthetic.main.dialog_recycler_view.* import kotlinx.android.synthetic.main.dialog_recycler_view.*
import kotlinx.android.synthetic.main.item_group_manage.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.menu.applyTint(requireContext(), false)
tool_bar.setOnMenuItemClickListener(this) tool_bar.setOnMenuItemClickListener(this)
tool_bar.menu.findItem(R.id.menu_group_local) 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) tool_bar.menu.findItem(R.id.menu_group_audio)
.isChecked = getPrefBoolean("bookGroupAudio", true) .isChecked = AppConst.bookGroupAudioShow
adapter = GroupAdapter(requireContext()) adapter = GroupAdapter(requireContext())
recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.layoutManager = LinearLayoutManager(requireContext())
recycler_view.addItemDecoration( recycler_view.addItemDecoration(
@ -88,12 +91,12 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
R.id.menu_add -> addGroup() R.id.menu_add -> addGroup()
R.id.menu_group_local -> { R.id.menu_group_local -> {
item.isChecked = !item.isChecked item.isChecked = !item.isChecked
putPrefBoolean("bookGroupLocal", item.isChecked) AppConst.bookGroupLocalShow = item.isChecked
callBack?.upGroup() callBack?.upGroup()
} }
R.id.menu_group_audio -> { R.id.menu_group_audio -> {
item.isChecked = !item.isChecked item.isChecked = !item.isChecked
putPrefBoolean("bookGroupAudio", item.isChecked) AppConst.bookGroupAudioShow = item.isChecked
callBack?.upGroup() callBack?.upGroup()
} }
} }

Loading…
Cancel
Save