Skip to content

Instantly share code, notes, and snippets.

View n0m0r3pa1n's full-sized avatar

Georgi Mirchev n0m0r3pa1n

View GitHub Profile
@n0m0r3pa1n
n0m0r3pa1n / ListAdapterStrategy.kt
Created July 7, 2022 08:52
ListAdapterStrategy for Android mobile and TV
class MobileListAdapterStrategy<T : Any, VH : RecyclerView.ViewHolder>(
override val adapter: RecyclerView.Adapter<VH>,
private val diffCallback: DiffUtil.ItemCallback<T>
) : ListAdapterStrategy<T, VH> {
private val listAdapter = object : ListAdapter<T, VH>(diffCallback) {
fun getItemWithPosition(position: Int) = getItem(position)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
return this.onCreateViewHolder(parent, viewType)
}