feat: 优化代码

pull/167/head
kunfei 5 years ago
parent f0f5e699b9
commit c7b2e1c7b2
  1. 4
      app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt

@ -50,8 +50,8 @@ class DiffCallBack(private val oldItems: List<SearchBook>, private val newItems:
override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? { override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? {
val payload = Bundle() val payload = Bundle()
val newItem: SearchBook? = if ((newItemPosition >= 0) && (newItemPosition < newItems.size)) newItems[newItemPosition] else null val newItem = newItems.getOrNull(newItemPosition)
val oldItem: SearchBook? = if ((oldItemPosition >= 0) && (oldItemPosition < oldItems.size)) oldItems[oldItemPosition] else null val oldItem = oldItems.getOrNull(oldItemPosition)
if (newItem == null) return payload if (newItem == null) return payload
if (oldItem?.name != newItem.name) { if (oldItem?.name != newItem.name) {
payload.putString("name", newItem.name) payload.putString("name", newItem.name)

Loading…
Cancel
Save