CollectionItem

abstract class CollectionItem<V : View>(val id: Int, val viewType: Int, var renderInfo: RenderInfo)

Abstract class representing an item in a collection that can be rendered as a child view of a collection. This class provides the foundation for managing collection items with their rendering lifecycle.

Parameters

V

The type of View this collection item represents

Inheritors

Constructors

Link copied to clipboard
constructor(id: Int, viewType: Int, renderInfo: RenderInfo)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val id: Int

The unique identifier for this item in the RecyclerView.Adapter

Link copied to clipboard

Contains information about how to render this item

Link copied to clipboard
abstract val size: Size?

Returns the size of this collection item.

Link copied to clipboard
abstract val sizeConstraints: SizeConstraints?

Returns the size constraints that define the measurement boundaries for this collection item. These constraints specify the minimum and maximum width and height values that should be used when measuring and laying out the item.

Link copied to clipboard

The type identifier used for this item in the RecyclerView.Adapter

Functions

Link copied to clipboard
fun CollectionItem<*>.areSizeConstraintsCompatible(constraints: SizeConstraints): Boolean

Checks if the provided size constraints are compatible with this CollectionItem's current size constraints and measured size.

Link copied to clipboard
abstract fun measure(sizeConstraints: SizeConstraints, result: IntArray?)

Measures the item according to the given size constraints.

Link copied to clipboard
abstract fun onBindView(view: V, sizeConstraints: SizeConstraints)

Binds data and properties to the view when it's being displayed in the collection. This method is called when the RecyclerView needs to display the item at a specific position.

Link copied to clipboard
abstract fun onViewRecycled(view: V)

Called when a view has been recycled and is no longer being displayed in the collection. This method should clean up any resources, listeners, or bindings associated with the view to prevent memory leaks and ensure proper recycling behavior.

Link copied to clipboard
abstract fun prepare(sizeConstraints: SizeConstraints)

To prepare the item for rendering in async way. This is going to be used in the range preparation.

Link copied to clipboard
abstract fun prepareSync(sizeConstraints: SizeConstraints, result: IntArray?)

To prepare the item for rendering in sync way.

Link copied to clipboard
abstract fun unprepare()

To unprepare the item, which is called after the item is being released by the range preparation.