pull/433/head
gedoor 4 years ago
parent 8d67962f36
commit ea73c34f5d
  1. 3
      app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt
  2. 5
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  3. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt

@ -31,6 +31,9 @@ interface BookGroupDao {
@get:Query("SELECT * FROM book_groups ORDER BY `order`")
val all: List<BookGroup>
@Query("update book_groups set show = 1 where groupId = :groupId")
fun enableGroup(groupId: Long)
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg bookGroup: BookGroup)

@ -164,13 +164,16 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
}
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
return true
val oldItem = oldItems[oldItemPosition]
val newItem = newItems[newItemPosition]
return oldItem.groupId == newItem.groupId
}
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
val oldItem = oldItems[oldItemPosition]
val newItem = newItems[newItemPosition]
return oldItem.groupName == newItem.groupName
&& oldItem.show == newItem.show
}
}

@ -12,6 +12,7 @@ import com.google.android.material.tabs.TabLayout
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.VMBaseFragment
import io.legado.app.constant.AppConst
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.BookGroup
@ -123,11 +124,15 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
@Synchronized
private fun upGroup(data: List<BookGroup>) {
if (data.isEmpty()) {
App.db.bookGroupDao().enableGroup(AppConst.bookGroupAllId)
} else {
bookGroups.clear()
bookGroups.addAll(data)
adapter.notifyDataSetChanged()
selectLastTab()
}
}
@Synchronized
private fun selectLastTab() {

Loading…
Cancel
Save