diff --git a/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt b/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt index 5f56d623f..815c6cbda 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt @@ -16,6 +16,9 @@ interface BookGroupDao { @Query("SELECT * FROM book_groups ORDER BY `order`") fun liveDataAll(): LiveData> + @Query("SELECT * FROM book_groups where groupId >= 0 ORDER BY `order`") + fun liveDataSelect(): LiveData> + @get:Query("SELECT sum(groupId) FROM book_groups") val idsSum: Long diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt index 9cf7b8ac1..f648527cb 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt @@ -109,7 +109,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener } private fun initData() { - App.db.bookGroupDao().liveDataAll().observe(viewLifecycleOwner, { + App.db.bookGroupDao().liveDataSelect().observe(viewLifecycleOwner, { adapter.setItems(it) }) } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt index ae14b99f9..afd80af8e 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt @@ -64,7 +64,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application) fun checkGroup(groups: List) { groups.forEach { group -> - if (group.groupId > 0 && group.groupId and (group.groupId - 1) != 0L) { + if (group.groupId >= 0 && group.groupId and (group.groupId - 1) != 0L) { var id = 1L val idsSum = App.db.bookGroupDao().idsSum while (id and idsSum != 0L) {