Skip to content

Instantly share code, notes, and snippets.


illuzor/AbstractAdapter.kt Secret

Created Sep 17, 2018
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>) {
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