class CreditCardsAdapter( private val interactor: CreditCardsManagementInteractor, ) : ListAdapter<CreditCard, CreditCardItemViewHolder>(DiffCallback) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CreditCardItemViewHolder { val view = LayoutInflater.from(parent.context) .inflate(CreditCardItemViewHolder.LAYOUT_ID, parent, false) return CreditCardItemViewHolder(view, interactor) } override fun onBindViewHolder(holder: CreditCardItemViewHolder, position: Int) { holder.bind(getItem(position)) } internal object DiffCallback : DiffUtil.ItemCallback<CreditCard>() { override fun areItemsTheSame(oldItem: CreditCard, newItem: CreditCard) = oldItem.guid == newItem.guid override fun areContentsTheSame(oldItem: CreditCard, newItem: CreditCard) = oldItem == newItem } }
Adapter for a list of credit cards to be displayed.