feat: 优化代码

pull/190/head
kunfei 5 years ago
parent 8f88574fb3
commit af95e19788
  1. 4
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  2. 10
      app/src/main/res/menu/book_group_manage.xml

@ -110,8 +110,10 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
} }
var noGroupSize = 0 var noGroupSize = 0
withContext(IO) { withContext(IO) {
if (AppConfig.bookGroupNoneShow) {
noGroupSize = App.db.bookDao().noGroupSize noGroupSize = App.db.bookDao().noGroupSize
} }
}
synchronized(this@BookshelfFragment) { synchronized(this@BookshelfFragment) {
bookGroups.clear() bookGroups.clear()
if (AppConfig.bookGroupAllShow) { if (AppConfig.bookGroupAllShow) {
@ -162,8 +164,10 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
launch { launch {
var noGroupSize = 0 var noGroupSize = 0
withContext(IO) { withContext(IO) {
if (AppConfig.bookGroupNoneShow) {
noGroupSize = App.db.bookDao().noGroupSize noGroupSize = App.db.bookDao().noGroupSize
} }
}
synchronized(this@BookshelfFragment) { synchronized(this@BookshelfFragment) {
bookGroups.remove(AppConst.bookGroupAll) bookGroups.remove(AppConst.bookGroupAll)
bookGroups.remove(AppConst.bookGroupLocal) bookGroups.remove(AppConst.bookGroupLocal)

@ -10,6 +10,8 @@
app:showAsAction="always" app:showAsAction="always"
tools:ignore="AlwaysShowAction" /> tools:ignore="AlwaysShowAction" />
<group android:id="@+id/menu_groups">
<item <item
android:id="@+id/menu_group_all" android:id="@+id/menu_group_all"
android:title="@string/all" android:title="@string/all"
@ -21,21 +23,23 @@
android:id="@+id/menu_group_local" android:id="@+id/menu_group_local"
android:title="@string/local" android:title="@string/local"
android:checkable="true" android:checkable="true"
android:checked="true" android:checked="false"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/menu_group_audio" android:id="@+id/menu_group_audio"
android:title="@string/audio" android:title="@string/audio"
android:checkable="true" android:checkable="true"
android:checked="true" android:checked="false"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/menu_group_none" android:id="@+id/menu_group_none"
android:title="@string/no_group" android:title="@string/no_group"
android:checkable="true" android:checkable="true"
android:checked="true" android:checked="false"
app:showAsAction="never" /> app:showAsAction="never" />
</group>
</menu> </menu>
Loading…
Cancel
Save