pull/37/head
parent
091d2508fd
commit
2a53b94754
@ -0,0 +1,33 @@ |
||||
package io.legado.app.ui.main.bookshelf |
||||
|
||||
import androidx.recyclerview.widget.DiffUtil |
||||
import io.legado.app.data.entities.Book |
||||
|
||||
class BooksDiffCallBack(private val oldItems: List<Book>, private val newItems: List<Book>) : |
||||
DiffUtil.Callback() { |
||||
|
||||
|
||||
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { |
||||
return oldItems[oldItemPosition].bookUrl == newItems[newItemPosition].bookUrl |
||||
} |
||||
|
||||
override fun getOldListSize(): Int { |
||||
return oldItems.size |
||||
} |
||||
|
||||
override fun getNewListSize(): Int { |
||||
return newItems.size |
||||
} |
||||
|
||||
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { |
||||
val oldItem = oldItems[oldItemPosition] |
||||
val newItem = newItems[newItemPosition] |
||||
return oldItem.name == newItem.name |
||||
&& oldItem.durChapterTitle == newItem.durChapterTitle |
||||
&& oldItem.latestChapterTitle == newItem.latestChapterTitle |
||||
&& oldItem.getDisplayCover() == newItem.getDisplayCover() |
||||
&& oldItem.getUnreadChapterNum() == newItem.getUnreadChapterNum() |
||||
&& oldItem.lastCheckCount == newItem.lastCheckCount |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue