Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.illuzor.lesson.wallpapers.adapters
import androidx.recyclerview.widget.RecyclerView
abstract class AbstractAdapter<T, VH : RecyclerView.ViewHolder> : RecyclerView.Adapter<VH>() {
private val items = mutableListOf<T>()
protected lateinit var clickListener: (String) -> Unit
fun setOnclickListener(clickListener: (String) -> Unit) {
this.clickListener = clickListener
}
fun addItems(items: List<T>) {
this.items.addAll(items)
notifyDataSetChanged()
}
override fun getItemCount() = items.size
protected fun getItem(position: Int): T = items[position]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment