Created
January 25, 2020 00:29
-
-
Save danielmalone/31a0214f3dcec895444423c2d1e034a9 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.danielmalone.dansinvoicing | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.recyclerview.widget.DiffUtil | |
import androidx.recyclerview.widget.ListAdapter | |
import androidx.recyclerview.widget.RecyclerView | |
class InvoicesAdapter : ListAdapter<Invoice, InvoicesAdapter.ViewHolder>(InvoicesDiff()) { | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
val inflater = LayoutInflater.from(parent.context) | |
return ViewHolder(inflater.inflate(R.layout.invoice_row, parent, false)) | |
} | |
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | |
} | |
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { | |
} | |
} | |
class InvoicesDiff : DiffUtil.ItemCallback<Invoice>() { | |
override fun areItemsTheSame(oldItem: Invoice, newItem: Invoice): Boolean { | |
return oldItem.id == newItem.id | |
} | |
override fun areContentsTheSame(oldItem: Invoice, newItem: Invoice): Boolean { | |
return areItemsTheSame(oldItem, newItem) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment