Recycler View Configuration

class RecyclerViewConfiguration<model : Any>(    var layoutManager: RecyclerView.LayoutManager? = null,     var devAdapter: DevRecyclerViewAdapter<model>? = null,     var pagination: Boolean = false,     var loadMoreListener: OnLoadMoreListener? = null,     var onClickListener: (model?) -> Unit? = null,     var ongLongClickListener: (model?) -> Unit? = null)

Class for containing RecyclerView configuration in extension function

Author

Jimly A.

Since

06-Oct-21

Parameters

model

Object model for the RecyclerView

devAdapter

RecyclerView Adapter from codebase

pagination

does the RecyclerView use Pagination?

loadMoreListener

Load More listener for the RecyclerView

onClickListener

Click Listener for the item

ongLongClickListener

on Long click listener for the item

Constructors

Link copied to clipboard
fun <model : Any> RecyclerViewConfiguration(    layoutManager: RecyclerView.LayoutManager? = null,     devAdapter: DevRecyclerViewAdapter<model>? = null,     pagination: Boolean = false,     loadMoreListener: OnLoadMoreListener? = null,     onClickListener: (model?) -> Unit? = null,     ongLongClickListener: (model?) -> Unit? = null)

return RecyclerView Configuration

Functions

Link copied to clipboard
inline fun <viewBinding : ViewBinding> withBinding(crossinline onBind: (model?, viewBinding) -> Unit)

method to configure item Binding

Link copied to clipboard
fun withClick(onClick: (model?) -> Unit)

method to define action when item is clicked

Link copied to clipboard
fun withLayoutManager(layoutManager: RecyclerView.LayoutManager?)

method to configure layout manager

Link copied to clipboard
fun withLongClick(ongLongClick: (model?) -> Unit)

method to define action when item is long clicked

Link copied to clipboard
fun withPagination(onLoadMoreListener: OnLoadMoreListener)

method to define does the RecyclerView support pagination?

Properties

Link copied to clipboard
var devAdapter: DevRecyclerViewAdapter<model>? = null
Link copied to clipboard
var layoutManager: RecyclerView.LayoutManager? = null
Link copied to clipboard
var loadMoreListener: OnLoadMoreListener? = null
Link copied to clipboard
var onClickListener: (model?) -> Unit? = null
Link copied to clipboard
var ongLongClickListener: (model?) -> Unit? = null
Link copied to clipboard
var pagination: Boolean = false

Sources

Link copied to clipboard