pull/433/head
gedoor 4 years ago
parent e38e52b683
commit 8ffc204ae2
  1. 3
      app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  3. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt

@ -16,6 +16,9 @@ interface BookGroupDao {
@Query("SELECT * FROM book_groups ORDER BY `order`") @Query("SELECT * FROM book_groups ORDER BY `order`")
fun liveDataAll(): LiveData<List<BookGroup>> fun liveDataAll(): LiveData<List<BookGroup>>
@Query("SELECT * FROM book_groups where groupId >= 0 ORDER BY `order`")
fun liveDataSelect(): LiveData<List<BookGroup>>
@get:Query("SELECT sum(groupId) FROM book_groups") @get:Query("SELECT sum(groupId) FROM book_groups")
val idsSum: Long val idsSum: Long

@ -109,7 +109,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
private fun initData() { private fun initData() {
App.db.bookGroupDao().liveDataAll().observe(viewLifecycleOwner, { App.db.bookGroupDao().liveDataSelect().observe(viewLifecycleOwner, {
adapter.setItems(it) adapter.setItems(it)
}) })
} }

@ -64,7 +64,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
fun checkGroup(groups: List<BookGroup>) { fun checkGroup(groups: List<BookGroup>) {
groups.forEach { group -> 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 var id = 1L
val idsSum = App.db.bookGroupDao().idsSum val idsSum = App.db.bookGroupDao().idsSum
while (id and idsSum != 0L) { while (id and idsSum != 0L) {

Loading…
Cancel
Save