Merge pull request #165 from yangyxd/master

修复搜索时cash问题
pull/167/head
kunfei 5 years ago committed by GitHub
commit f0f5e699b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt

@ -49,28 +49,29 @@ class DiffCallBack(private val oldItems: List<SearchBook>, private val newItems:
}
override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? {
val oldItem = oldItems[oldItemPosition]
val newItem = newItems[newItemPosition]
val payload = Bundle()
if (oldItem.name != newItem.name) {
val newItem: SearchBook? = if ((newItemPosition >= 0) && (newItemPosition < newItems.size)) newItems[newItemPosition] else null
val oldItem: SearchBook? = if ((oldItemPosition >= 0) && (oldItemPosition < oldItems.size)) oldItems[oldItemPosition] else null
if (newItem == null) return payload
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)
}
return payload

Loading…
Cancel
Save