Package-level declarations

Types

Link copied to clipboard
abstract class AbstractViewBindingAdapter<T, VH : RecyclerView.ViewHolder, VB : ViewBinding>(viewHolder: (binding: VB) -> VH, bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB, areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, onCreateBinding: (holder: VH) -> Unit = {}) : ListAdapter<T, VH>

Takes leverage of not providing that damn layout res id

abstract class AbstractViewBindingAdapterSingleSelection<T, VH : RecyclerView.ViewHolder, VB : ViewBinding>(viewHolder: (binding: VB) -> VH, bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB, areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, onCreateBinding: (holder: VH) -> Unit = {}) : ListAdapter<T, VH>

Takes leverage of not providing that damn layout res id

Link copied to clipboard
abstract class AbstractViewBindingCleanAdapter<T, VB : ViewBinding>(bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB, areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }) : ListAdapter<T, AbstractViewBindingCleanAdapter.AbstractViewHolder<VB>>

Takes leverage of not providing that damn layout res id

Link copied to clipboard
abstract class AbstractViewBindingHolderAdapter<T, VB : ViewBinding>(bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB, areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, onCreateBinding: (holder: AbstractViewBindingHolderAdapter.AbstractViewHolder<VB>) -> Unit = {}) : ListAdapter<T, AbstractViewBindingHolderAdapter.AbstractViewHolder<VB>>

Takes leverage of not providing that damn layout res id

Link copied to clipboard
class AutoFitGridLayoutManager(context: Context, columnWidth: Int) : GridLayoutManager

layout width must be match parent

Link copied to clipboard
class GenericDiffUtil<T>(areItemsTheSameCallback: (old: T, new: T) -> Boolean?, areContentsTheSameCallback: (old: T, new: T) -> Boolean?) : DiffUtil.ItemCallback<T>

Use T as data class preferably if you don't pass anything in constructors

Link copied to clipboard
abstract class HideOnScrollListener(HIDE_THRESHOLD: Int = 20) : RecyclerView.OnScrollListener
Link copied to clipboard
Link copied to clipboard
interface MenuClicker
Link copied to clipboard
Link copied to clipboard
class OrientationAwareRecyclerView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : RecyclerView
Link copied to clipboard

/* USAGE val sectionItemDecoration = RecyclerSectionItemDecoration(R.id.list_item_section_text, R.layout.section_header object : RecyclerSectionItemDecoration.SectionCallback {

Link copied to clipboard
class RecyclerSectionItemDecoration(headerOffset: Int, sticky: Boolean, sectionCallback: RecyclerSectionItemDecoration.SectionCallback, headerViewID: Int, sectionHeaderLayoutName: Int) : RecyclerView.ItemDecoration

/* USAGE val sectionItemDecoration = RecyclerSectionItemDecoration(resources.getDimensionPixelSize(R.dimen.recycler_section_header_height), false, // true for sticky, false for not, R.id.list_item_section_text, R.layout.section_header object : RecyclerSectionItemDecoration.SectionCallback {

Link copied to clipboard
data class RecyclerSwipeItemHandler(var drawableLeft: Int? = null, var drawLeftBackground: Boolean = false, var leftBackgroundColor: Int? = null, var drawableRight: Int? = null, var drawRightBackground: Boolean = false, var rightBackgroundColor: Int? = null, var swipeDirection: RecyclerSwipeItemHandler.SwipeDirs = SwipeDirs.BOTH)
Link copied to clipboard
Link copied to clipboard
class ScrollStateHolder(savedInstanceState: Bundle? = null)

Persists scroll state for nested RecyclerViews.

Link copied to clipboard
class SpaceDecoration(start: Int = 0, top: Int = 0, end: Int = 0, bottom: Int = 0) : RecyclerView.ItemDecoration

ItemDecoration that adds space around items.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun <T> RecyclerView.addDrag(adapter: RecyclerView.Adapter<*>, adapterList: MutableList<T>)

Extension function for recyclerDrag

Link copied to clipboard
Link copied to clipboard
fun RecyclerView?.addSwipe(context: Context, leftAction: (swipedPosition: Int) -> Unit = { _ -> }, rightAction: (swipedPosition: Int) -> Unit = { _ -> }, recyclerSwipeItemHandler: RecyclerSwipeItemHandler.() -> Unit)

Extension function for recyclerSwipe

Link copied to clipboard
fun Context.calculateNoOfColumns(columnWidthDp: Float): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <T> diffUtilDSL(areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }): GenericDiffUtil<old: T>
Link copied to clipboard
Link copied to clipboard

Disable all user input to a recyclerview, passing touch events out

Link copied to clipboard
fun RecyclerView.divider(color: Int = Color.parseColor("#CCCCCC"), size: Int = 1): RecyclerView
Link copied to clipboard
fun RecyclerView.enableAnimations(addDuration: Long = 120, removeDuration: Long = 120, moveDuration: Long = 250, changeDuration: Long = 250)
Link copied to clipboard
fun Context.fullLinearRecycler(rvAdapter: RecyclerView.Adapter<*>? = null, configs: RecyclerView.() -> Unit = {}): RecyclerView

Generates a recycler view with match parent and a linearlayoutmanager, since it's so commonly used

Link copied to clipboard
fun RecyclerView.fullScreenGestureNavigation(fragmentActivity: FragmentActivity, topInset: Int = 200, bottomInset: Int = 40)
Link copied to clipboard
inline fun <T, VH : RecyclerView.ViewHolder, VB : ViewBinding> RecyclerView.generateHorizontalAdapter(noinline viewHolder: (binding: VB) -> VH, noinline bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB, noinline areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, noinline areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, crossinline binder: (item: T, holder: VH, position: Int, itemCount: Int) -> Unit, hasFixedSize: Boolean = false, reverseLayout: Boolean = false): AbstractViewBindingAdapter<T, VH, VB>
Link copied to clipboard
inline fun <T, VB : ViewBinding> RecyclerView.generateHorizontalAdapterWithHolder(noinline bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB, noinline areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, noinline areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, noinline onCreateBinding: (holder: AbstractViewBindingHolderAdapter.AbstractViewHolder<VB>) -> Unit = {}, crossinline binder: (item: T, position: Int, itemCount: Int, binding: VB, context: Context) -> Unit, hasFixedSize: Boolean = false, reverseLayout: Boolean = false): AbstractViewBindingHolderAdapter<T, VB>
Link copied to clipboard
inline fun <T, VH : RecyclerView.ViewHolder, VB : ViewBinding> generateRecycler(noinline viewHolder: (binding: VB) -> VH, noinline bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB, noinline areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, noinline areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, crossinline binder: (item: T, holder: VH, position: Int, itemCount: Int) -> Unit): AbstractViewBindingAdapter<T, VH, VB>
Link copied to clipboard
inline fun <T, VB : ViewBinding> generateRecyclerWithHolder(noinline bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB, noinline areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, noinline areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, noinline onCreateBinding: (holder: AbstractViewBindingHolderAdapter.AbstractViewHolder<VB>) -> Unit = {}, crossinline binder: (item: T, position: Int, itemCount: Int, binding: VB, context: Context) -> Unit): AbstractViewBindingHolderAdapter<T, VB>
Link copied to clipboard
inline fun <T, VH : RecyclerView.ViewHolder, VB : ViewBinding> RecyclerView.generateVerticalAdapter(noinline viewHolder: (binding: VB) -> VH, noinline bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB, noinline areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, noinline areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, crossinline binder: (item: T, holder: VH, position: Int, itemCount: Int) -> Unit, hasFixedSize: Boolean = false, reverseLayout: Boolean = false): AbstractViewBindingAdapter<T, VH, VB>
Link copied to clipboard
inline fun <T, VB : ViewBinding> RecyclerView.generateVerticalAdapterWithHolder(noinline bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB, noinline areItemsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, noinline areContentsTheSameCallback: (old: T, new: T) -> Boolean? = { _, _ -> null }, noinline onCreateBinding: (holder: AbstractViewBindingHolderAdapter.AbstractViewHolder<VB>) -> Unit = {}, crossinline binder: (item: T, position: Int, itemCount: Int, binding: VB, context: Context) -> Unit, hasFixedSize: Boolean = false, reverseLayout: Boolean = false): AbstractViewBindingHolderAdapter<T, VB>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

To prevent the RecyclerView stealing touches from the bottom sheet fragment or any other fragment that scrolls, use this function If you're using other recycler views besides this one, use OrientationAwareRecyclerView for them

Link copied to clipboard
inline fun RecyclerView.hideOnScroll(threshold: Int = 20, crossinline hide: () -> Unit = {}, crossinline show: () -> Unit = {})
Link copied to clipboard
fun RecyclerView.horizontal(spanCount: Int = 0, isStaggered: Boolean = false): RecyclerView
Link copied to clipboard
fun RecyclerView.horizontalDivider(drawable: Drawable, dividerSize: Int = drawable.intrinsicHeight.coerceAtLeast(1), padding: Int = 0)

Adds an RecyclerView.ItemDecoration that draws a horizontal divider between items.

Link copied to clipboard
fun <T : RecyclerView.Adapter<*>> RecyclerView.initRecyclerViewAdapter(yourAdapter: T, yourLayoutManager: RecyclerView.LayoutManager, fixedSize: Boolean = false)
fun <T : RecyclerView.Adapter<*>> RecyclerView.initRecyclerViewAdapter(yourAdapter: T, layoutOrientation: Int = RecyclerView.VERTICAL, fixedSize: Boolean = false, reverseLayout: Boolean = false)

Set adapter of recyclerView

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun RecyclerView.Adapter<*>.onItemRangeChanged(action: (positionStart: Int, itemCount: Int) -> Unit = { _, _ -> }): RecyclerView.AdapterDataObserver
fun RecyclerView.Adapter<*>.onItemRangeChanged(action: (positionStart: Int, itemCount: Int, payload: Any?) -> Unit = { _, _, _ -> }): RecyclerView.AdapterDataObserver
Link copied to clipboard
fun RecyclerView.Adapter<*>.onItemRangeInserted(action: (positionStart: Int, itemCount: Int) -> Unit = { _, _ -> }): RecyclerView.AdapterDataObserver
Link copied to clipboard
fun RecyclerView.Adapter<*>.onItemRangeMoved(action: (fromPosition: Int, toPosition: Int, itemCount: Int) -> Unit = { _, _, _ -> }): RecyclerView.AdapterDataObserver
Link copied to clipboard
fun RecyclerView.Adapter<*>.onItemRangeRemoved(action: (positionStart: Int, itemCount: Int) -> Unit = { _, _ -> }): RecyclerView.AdapterDataObserver
Link copied to clipboard
fun <T> recyclerChangeItemAtPosition(adapterList: MutableList<T>, adapter: RecyclerView.Adapter<*>, positionForChanging: Int, itemToChange: T)
Link copied to clipboard
fun <T> recyclerDeleteItem(adapterList: MutableList<T>, adapter: RecyclerView.Adapter<*>, positionForDeletion: Int)
Link copied to clipboard
fun <T> recyclerDeleteItems(list: MutableList<T>, adapter: RecyclerView.Adapter<*>, position: Int)
Link copied to clipboard
fun <T> recyclerDeleteItemWithUndo(adapterList: MutableList<T>, adapter: RecyclerView.Adapter<*>, positionForDeletion: Int, rootLayout: View)
Link copied to clipboard
fun <T> recyclerDrag(adapter: RecyclerView.Adapter<*>, adapterList: MutableList<T>): ItemTouchHelper

Don't forget to call ItemTouchHelper.attachToRecyclerView on this since it returns ItemTouchHelper or use addDrag as an extension function

Link copied to clipboard
fun <T> recyclerInsertItemOnLastPosition(adapterList: MutableList<T>, adapter: RecyclerView.Adapter<*>, itemToInsert: T)
Link copied to clipboard
fun <T> recyclerInsertMultipleItems(adapterList: MutableList<T>, adapter: RecyclerView.Adapter<*>, insertionStartsAt: Int, listToInsert: MutableList<T>)
Link copied to clipboard
fun recyclerSwipe(context: Context, leftAction: (swipedPosition: Int) -> Unit = { _ -> }, rightAction: (swipedPosition: Int) -> Unit = { _ -> }, recyclerSwipeItemHandler: RecyclerSwipeItemHandler.() -> Unit): ItemTouchHelper

Don't forget to call ItemTouchHelper.attachToRecyclerView on this since it returns ItemTouchHelper or use addSwipe

Link copied to clipboard
fun RecyclerView.replaceAdapterWith(replacementAdapter: RecyclerView.Adapter<*>, transition: Transition? = null, onAnimator: (RecyclerView.ItemAnimator?) -> Unit)
Link copied to clipboard
fun RecyclerView.scrollListener(onScrollStateChanged: (recycler: RecyclerView, newState: Int) -> Unit = { _, _ -> }, onScrolled: (recycler: RecyclerView, scrollbyX: Int, scrollbyY: Int) -> Unit = { _, _, _ -> })
Link copied to clipboard
fun RecyclerView.setAppBarElevationListener(appBar: AppBarLayout, elevation: Float = 8.0f)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun RecyclerView.smoothScrollTo(position: Int, callback: () -> Unit? = null)
Link copied to clipboard
fun RecyclerView.smoothSnapToPosition(position: Int, performClick: Boolean = true)
Link copied to clipboard
fun RecyclerView.vertical(spanCount: Int = 0, isStaggered: Boolean = false): RecyclerView
Link copied to clipboard
fun RecyclerView.verticalDivider(drawable: Drawable, dividerSize: Int = drawable.intrinsicHeight.coerceAtLeast(1), padding: Int = 0)

Adds an RecyclerView.ItemDecoration that draws a vertical divider between items.

Link copied to clipboard

Set a GridLayoutManager as this layoutManager.

Link copied to clipboard

Sets a linear layout manager along with an adapter

Link copied to clipboard
fun RecyclerView.withLinearLayoutManager(vertical: Boolean = true, reversed: Boolean = false): RecyclerView

Set a LinearLayoutManager as this layoutManager.