feat: 优化代码

pull/190/head
kunfei 5 years ago
parent af385b71e8
commit 8f88574fb3
  1. 6
      app/src/main/java/io/legado/app/help/AppConfig.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  4. 7
      app/src/main/res/menu/book_group_manage.xml

@ -115,6 +115,12 @@ object AppConfig {
App.INSTANCE.putPrefBoolean("bookGroupAudio", value)
}
var bookGroupNoneShow: Boolean
get() = App.INSTANCE.getPrefBoolean("bookGroupNone", false)
set(value) {
App.INSTANCE.putPrefBoolean("bookGroupNone", value)
}
var elevation: Int
get() = App.INSTANCE.getPrefInt("elevation", -1)
set(value) {

@ -99,6 +99,8 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
.isChecked = AppConfig.bookGroupLocalShow
it.findItem(R.id.menu_group_audio)
.isChecked = AppConfig.bookGroupAudioShow
it.findItem(R.id.menu_group_none)
.isChecked = AppConfig.bookGroupNoneShow
}
}
@ -120,6 +122,10 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
AppConfig.bookGroupAudioShow = item.isChecked
callBack?.upGroup()
}
R.id.menu_group_none -> {
item.isChecked = !item.isChecked
AppConfig.bookGroupNoneShow = item.isChecked
}
}
return true
}

@ -94,8 +94,10 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
tool_bar.inflateMenu(R.menu.book_group_manage)
tool_bar.menu.applyTint(requireContext(), Theme.getTheme())
tool_bar.setOnMenuItemClickListener(this)
tool_bar.menu.findItem(R.id.menu_group_all).isVisible = false
tool_bar.menu.findItem(R.id.menu_group_local).isVisible = false
tool_bar.menu.findItem(R.id.menu_group_audio).isVisible = false
tool_bar.menu.findItem(R.id.menu_group_none).isVisible = false
adapter = GroupAdapter(requireContext())
recycler_view.layoutManager = LinearLayoutManager(requireContext())
recycler_view.addItemDecoration(VerticalDivider(requireContext()))

@ -31,4 +31,11 @@
android:checked="true"
app:showAsAction="never" />
<item
android:id="@+id/menu_group_none"
android:title="@string/no_group"
android:checkable="true"
android:checked="true"
app:showAsAction="never" />
</menu>
Loading…
Cancel
Save