Skip to content

Instantly share code, notes, and snippets.

Avatar

John Lombardo johnnylambada

View GitHub Profile
View AnkoRecyclerViewAdapter.kt
abstract class AnkoRecyclerViewAdapter<Model : Any, AnkoView : AnkoComponent<ViewGroup>, ViewHolder : RecyclerView.ViewHolder> : RecyclerView.Adapter<ViewHolder>() {
abstract val data: List<Model> // Data list
abstract val ankoView: AnkoView // Layout as AnkoComponent<ViewGroup>
abstract fun ViewHolder.setup(model: Model) // setup model from ViewHolder
abstract val onItemClickListenerUnit: (Model) -> Unit // Item Click Listener
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.setup(data[position])
holder.itemView.setOnClickListener {