Slide 15
Slide 15 text
…..ARCHITECTURE - PAGING - UI Component
class ConcertPagedListAdapter() : PagedListAdapter(
object : DiffUtil.ItemCallback() {
// The ID property identifies when items are the same.
override fun areItemsTheSame(oldItem: Concert, newItem: Concert)
= oldItem.id = newItem.id
// Use the "==" operator (or Object.equals() in Java-based code) to know
// when an item's content changes. Implement equals(), or write custom
// data comparison logic here.
override fun areContentsTheSame(oldItem: Concert, newItem: Concert) =
oldItem.name == newItem.name && oldItem.date == newItem.date
}
) {
override fun onBindViewHolder(holder: ConcertViewHolder, position: Int) {
val concert: Concert? = getItem(position)
// Note that "concert" is a placeholder if it's null
holder.bind(concert)
}
}