diff --git a/app/src/main/java/io/legado/app/ui/search/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/search/DiffCallBack.kt new file mode 100644 index 000000000..b38514f50 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/search/DiffCallBack.kt @@ -0,0 +1,28 @@ +package io.legado.app.ui.search + +import androidx.recyclerview.widget.DiffUtil +import io.legado.app.data.entities.SearchShow + +class DiffCallBack(private val oldItems: List, private val newItems: List) : + DiffUtil.Callback() { + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + return oldItems[oldItemPosition].name == newItems[newItemPosition].name + && oldItems[oldItemPosition].author == newItems[newItemPosition].author + } + + override fun getOldListSize(): Int { + return oldItems.size + } + + override fun getNewListSize(): Int { + return newItems.size + } + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + return oldItems[oldItemPosition].originCount == newItems[newItemPosition].originCount + } + + override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? { + return super.getChangePayload(oldItemPosition, newItemPosition) + } +} \ No newline at end of file