-
-
Save illuzor/e01c6798e5a7cf4d7ff9c216ab120de7 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.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