pull/433/head
gedoor 4 years ago
parent 14858b4d76
commit 15a8a506f0
  1. 3
      app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt
  2. 8
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt

@ -34,6 +34,9 @@ interface BookGroupDao {
@Query("update book_groups set show = 1 where groupId = :groupId")
fun enableGroup(groupId: Long)
@Query("select groupName from book_groups where groupId > 0 and (groupId & :id) > 0")
fun getGroupNames(id: Long): List<String>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg bookGroup: BookGroup)

@ -119,13 +119,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
fun loadGroup(groupId: Long, success: ((groupNames: String?) -> Unit)) {
execute {
val groupNames = arrayListOf<String>()
App.db.bookGroupDao().all.forEach {
if (groupId and it.groupId > 0) {
groupNames.add(it.groupName)
}
}
groupNames.joinToString(",")
App.db.bookGroupDao().getGroupNames(groupId).joinToString(",")
}.onSuccess {
success.invoke(it)
}

Loading…
Cancel
Save