Skip to content

Instantly share code, notes, and snippets.

View AAverin's full-sized avatar

Anton Averin AAverin

View GitHub Profile
@AAverin
AAverin / Cmpnt.kt
Created April 11, 2023 18:22
Component-based adapter
class CmpntViewHolder<T>(val cmpnt: Cmpnt<T>, view: View) : RecyclerView.ViewHolder(view)
abstract class Cmpnt<T>(@field:LayoutRes private val cmpntLayoutId: Int) {
open fun setData(data: T) {}
protected open fun onViewCreated(view: View) {}
fun createView(inflater: LayoutInflater, parent: ViewGroup?): View {
val view = inflater.inflate(cmpntLayoutId, parent, false)