From 153830e14318293b168523c6a183688110f26a43 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 7 Feb 2020 21:34:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/group/GroupManageDialog.kt | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) 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 ac49119bd..e4956c85b 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 @@ -78,12 +78,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { recycler_view.adapter = adapter App.db.bookGroupDao().liveDataAll().observe(viewLifecycleOwner, Observer { val diffResult = - DiffUtil.calculateDiff( - GroupDiffCallBack( - adapter.getItems(), - it - ) - ) + DiffUtil.calculateDiff(GroupDiffCallBack(ArrayList(adapter.getItems()), it)) adapter.setItems(it, false) diffResult.dispatchUpdatesTo(adapter) }) @@ -154,13 +149,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { private class GroupDiffCallBack( private val oldItems: List, private val newItems: List - ) : - DiffUtil.Callback() { - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { - val oldItem = oldItems[oldItemPosition] - val newItem = newItems[newItemPosition] - return oldItem.groupId == newItem.groupId - } + ) : DiffUtil.Callback() { override fun getOldListSize(): Int { return oldItems.size @@ -170,11 +159,14 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { return newItems.size } + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + return true + } + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { val oldItem = oldItems[oldItemPosition] val newItem = newItems[newItemPosition] return oldItem.groupName == newItem.groupName - && oldItem.order == newItem.order } }