From e9f40e699ec1c78589fe3a92c43bd77ef40c9e8c Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 19 Mar 2020 22:10:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/search/DiffCallBack.kt | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt index 999f2a941..b03e54fb7 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt @@ -50,30 +50,32 @@ class DiffCallBack(private val oldItems: List, private val newItems: override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? { val payload = Bundle() - val newItem = newItems.getOrNull(newItemPosition) - val oldItem = oldItems.getOrNull(oldItemPosition) - if (newItem == null) return payload - if (oldItem?.name != newItem.name) { + val newItem = newItems[newItemPosition] + val oldItem = oldItems[oldItemPosition] + if (oldItem.name != newItem.name) { payload.putString("name", newItem.name) } - if (oldItem?.author != newItem.author) { + if (oldItem.author != newItem.author) { payload.putString("author", newItem.author) } - if (oldItem?.origins?.size != newItem.origins.size) { + if (oldItem.origins.size != newItem.origins.size) { payload.putInt("origins", newItem.origins.size) } - if (oldItem?.coverUrl != newItem.coverUrl) { + if (oldItem.coverUrl != newItem.coverUrl) { payload.putString("cover", newItem.coverUrl) } - if (oldItem?.kind != newItem.kind) { + if (oldItem.kind != newItem.kind) { payload.putString("kind", newItem.kind) } - if (oldItem?.latestChapterTitle != newItem.latestChapterTitle) { + if (oldItem.latestChapterTitle != newItem.latestChapterTitle) { payload.putString("last", newItem.latestChapterTitle) } - if (oldItem?.intro != newItem.intro) { + if (oldItem.intro != newItem.intro) { payload.putString("intro", newItem.intro) } + if (payload.isEmpty) { + return null + } return payload } } \ No newline at end of file