recycler-view-divider / com.fondesa.recyclerviewdivider / BaseDividerItemDecoration

BaseDividerItemDecoration

abstract class BaseDividerItemDecoration : ItemDecoration

Base implementation of RecyclerView.ItemDecoration which provides some utilities methods. It also provides different implementations of getItemOffsets and onDraw.

Parameters

asSpace - true if the divider should behave as a space.

Constructors

<init>

BaseDividerItemDecoration(asSpace: Boolean)

Base implementation of RecyclerView.ItemDecoration which provides some utilities methods. It also provides different implementations of getItemOffsets and onDraw.

Functions

addTo

fun addTo(recyclerView: RecyclerView): Unit

Adds this decoration to the given RecyclerView. If this decoration was already added to the given RecyclerView, it will be removed first.

getItemOffsets

abstract fun getItemOffsets(layoutManager: LayoutManager, outRect: Rect, itemView: View, itemCount: Int, itemIndex: Int): Unit

Variation of RecyclerView.ItemDecoration.getItemOffsets which validates the RecyclerView before being notified.

fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: State): Unit
fun getItemOffsets(outRect: Rect, itemPosition: Int, parent: RecyclerView): Unit

onDraw

abstract fun onDraw(canvas: Canvas, recyclerView: RecyclerView, layoutManager: LayoutManager, itemCount: Int): Unit

Variation of RecyclerView.ItemDecoration.onDraw which validates the RecyclerView before being notified. This method will be invoked only if the divider shouldn't behave as a space since, if it's a space, it shouldn't draw anything.

fun onDraw(c: Canvas, parent: RecyclerView, state: State): Unit
fun onDraw(c: Canvas, parent: RecyclerView): Unit

removeFrom

fun removeFrom(recyclerView: RecyclerView): Unit

Removes this decoration from the given RecyclerView.