feat: 优化代码

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

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

@ -10,32 +10,36 @@
app:showAsAction="always" app:showAsAction="always"
tools:ignore="AlwaysShowAction" /> tools:ignore="AlwaysShowAction" />
<item <group android:id="@+id/menu_groups">
android:id="@+id/menu_group_all"
android:title="@string/all"
android:checkable="true"
android:checked="true"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_group_local" android:id="@+id/menu_group_all"
android:title="@string/local" android:title="@string/all"
android:checkable="true" android:checkable="true"
android:checked="true" android:checked="true"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/menu_group_audio" android:id="@+id/menu_group_local"
android:title="@string/audio" 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_none" android:id="@+id/menu_group_audio"
android:title="@string/no_group" android:title="@string/audio"
android:checkable="true" android:checkable="true"
android:checked="true" android:checked="false"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_group_none"
android:title="@string/no_group"
android:checkable="true"
android:checked="false"
app:showAsAction="never" />
</group>
</menu> </menu>
Loading…
Cancel
Save