ListViewDataSource

elements.ListViewDataSource (Class)

Data source implementation for ListView's collection view.

Handles the interface between ListView and its internal CellCollectionView, providing item data, managing cell creation and recycling, and binding cell behavior to list functionality.

See: CollectionViewDataSource, ListView, CellView

Instance Members

elements
collectionViewSize(collectionView: ceramic.CollectionView): Int

Returns the number of items in the collection.

Name Type Description
collectionView ceramic.CollectionView The requesting collection view
Returns Description
Int The number of items in the ListView's items array

elements
collectionViewItemFrameAtIndex(collectionView: ceramic.CollectionView, itemIndex: Int, frame: ceramic.CollectionViewItemFrame): Void

Configures the frame dimensions for an item at the specified index.

Sets the width to fill the collection view (minus scrollbar space if enabled) and height based on the smallItems setting.

Name Type Description
collectionView ceramic.CollectionView The requesting collection view
itemIndex Int The index of the item
frame ceramic.CollectionViewItemFrame The frame to configure

elements
collectionViewReleaseItemAtIndex(collectionView: ceramic.CollectionView, itemIndex: Int, view: ceramic.View): Bool

Called when a view is no longer needed at the given index.

Allows cleanup before view reuse. Currently always returns true to allow cell recycling for optimal performance.

Name Type Description
collectionView ceramic.CollectionView The requesting collection view
itemIndex Int The index where the view was used
view ceramic.View The view being released
Returns Description
Bool true if the view can be reused, false otherwise

elements
collectionViewItemAtIndex(collectionView: ceramic.CollectionView, itemIndex: Int, reusableView: ceramic.View): ceramic.View

Creates or recycles a view for the item at the specified index.

If a reusable view is provided, it's recycled and updated with the new item index. Otherwise, a new CellView is created and fully configured.

Name Type Description
collectionView ceramic.CollectionView The requesting collection view
itemIndex Int The index of the item to display
reusableView ceramic.View Optional view to recycle
Returns Description
ceramic.View A configured CellView for the item

elements
new(listView: ListView): Void

Creates a new data source for the specified ListView.

Name Type Description
listView ListView The ListView this data source serves

Private Members

elements
listView: ListView

Reference to the parent ListView


elements
bindCellView(cell: CellView): Void

Binds data and behavior to a CellView.

Sets up automatic data binding, theme updates, click handling, drag-and-drop behavior, and action handlers (trash, lock, duplicate) for the cell based on ListView configuration.

Name Type Description
cell CellView The CellView to bind

elements
handleCellDraggingChange(dragging: Bool, wasDragging: Bool): Void

Handles changes in cell dragging state.

Updates the collection view's items behavior to prevent recycling during drag operations for smoother interaction.

Name Type Description
dragging Bool Current dragging state
wasDragging Bool Previous dragging state

elements
handleCellDestroy(destroyed: ceramic.Entity): Void

Handles cell destruction.

Updates items behavior when a cell is destroyed to ensure proper state management.

Name Type Description
destroyed ceramic.Entity The destroyed entity

elements
updateItemsBehaviorFromDragging(): Void

Updates collection view behavior based on dragging state.

Switches between LAZY and RECYCLE behaviors:

  • LAZY: When any cell is being dragged (prevents recycling)
  • RECYCLE: When no cells are being dragged (allows recycling)

This ensures smooth drag interactions while maintaining performance.