Created
September 5, 2023 14:07
-
-
Save jonrysimbolon/a906cabb007ad86b2be7b9820cc34a21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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