Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. class BlogItemDiffCallback(
  2. var oldBlogList: List<BlogPost>,
  3. var newBlogList: List<BlogPost>
  4.  
  5. ): DiffUtil.Callback() {
  6.  
  7. override fun areItemsTheSame(
  8. oldItemPosition: Int,
  9. newItemPosition: Int
  10. ): Boolean {
  11. return (oldBlogList.get(oldItemPosition).pk
  12. == newBlogList.get(newItemPosition).pk)
  13. }
  14.  
  15. override fun getOldListSize(): Int {
  16. return oldBlogList.size
  17. }
  18.  
  19. override fun getNewListSize(): Int {
  20. return newBlogList.size
  21. }
  22.  
  23. override fun areContentsTheSame(
  24. oldItemPosition: Int,
  25. newItemPosition: Int
  26. ): Boolean {
  27. return (oldBlogList.get(oldItemPosition)
  28. == newBlogList.get(newItemPosition))
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement