Slide 19
Slide 19 text
X
© DMM.com
1BHFE-JTU"EBQUFS
internal class ItemAdapter(context: Context) : PagedListAdapter(ITEM_CALLBACK) {
companion object {
private val ITEM_CALLBACK = object : DiffUtil.ItemCallback() {
override fun areItemsTheSame(oldItem: Item, newItem: Item): Boolean = oldItem.id == newItem.id
override fun areContentsTheSame(oldItem: Item, newItem: Item): Boolean = oldItem == newItem
}
}
var onItemClickListener: OnItemClickListener? = null
private val inflater = LayoutInflater.from(context)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder =
ItemViewHolder.create(inflater, parent, false)
override fun onBindViewHolder(holder: ItemViewHolder, position: Int) =
holder.bind(getItem(position), onItemClickListener)
}