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 a7d29d750..4f65a751c 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 @@ -31,6 +31,9 @@ interface BookGroupDao { @get:Query("SELECT * FROM book_groups ORDER BY `order`") val all: List + @Query("update book_groups set show = 1 where groupId = :groupId") + fun enableGroup(groupId: Long) + @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(vararg bookGroup: BookGroup) diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt index 66fb7ebec..c39924f09 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt @@ -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 } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 1a0dfec74..33ac4ee78 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -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,10 +124,14 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b @Synchronized private fun upGroup(data: List) { - bookGroups.clear() - bookGroups.addAll(data) - adapter.notifyDataSetChanged() - selectLastTab() + if (data.isEmpty()) { + App.db.bookGroupDao().enableGroup(AppConst.bookGroupAllId) + } else { + bookGroups.clear() + bookGroups.addAll(data) + adapter.notifyDataSetChanged() + selectLastTab() + } } @Synchronized