Skip to content

Instantly share code, notes, and snippets.

@jonrysimbolon
Created September 5, 2023 14:07
Show Gist options
  • Save jonrysimbolon/a906cabb007ad86b2be7b9820cc34a21 to your computer and use it in GitHub Desktop.
Save jonrysimbolon/a906cabb007ad86b2be7b9820cc34a21 to your computer and use it in GitHub Desktop.
package com.jonrysimbolon.base.adapter
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.jonrysimbolon.base.model.BaseModel
abstract class BasePagingDataAdapter<I, T : BaseModel<I>, VH : RecyclerView.ViewHolder>
: PagingDataAdapter<T, VH>(object : DiffUtil.ItemCallback<T>() {
override fun areItemsTheSame(oldItem: T, newItem: T): Boolean {
return oldItem == newItem
}
override fun areContentsTheSame(oldItem: T, newItem: T): Boolean {
return newItem.id.toString() == oldItem.id.toString()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment