public interface

ColumnSpec

com.shinobicontrols.grids.core.ColumnSpec
Known Indirect Subclasses

Class Overview

Defines certain properties and behavior of a Column. A number of ready-made ColumnSpecs are provided with the library, such as the TextColumnSpec. Custom ColumnSpecs can also be created and given to the create(ColumnSpec) method.

ColumnSpecs should not be shared across different Columns.

Summary

Public Methods
abstract Parcelable createParcelable()
Creates a Parcelable which may be used to save the state of this Column.
abstract int getHeaderItemViewType()

Returns the item view type for the header of the Column this ColumnSpec describes.

abstract int getItemViewType(int rowIndex)

Returns the item view type for the given rowIndex in the grid.

abstract Integer getWidth()
Gets the width, in pixels which the Column which this ColumnSpec defines should adopt, the next time it is laid out.
abstract boolean hasHeader()

Returns whether the Column this ColumnSpec describes has a header or not.

abstract void initialize(Column.Callback callback)

Called when the Column is created, this method gives this ColumnSpec an opportunity to hold a reference to a callback object that provides controlled access to the Column via a number of useful methods.

abstract void onBindHeaderViewHolder(RecyclerView.ViewHolder holder)

Updates the contents of the item view for the header of the Column this ColumnSpec describes.

abstract void onBindViewHolder(RecyclerView.ViewHolder holder, int rowIndex)

Updates the contents of the item view to reflect the given rowIndex.

abstract void onColumnAdded(Context context)

Notifies this ColumnSpec that the Column it belongs to has been added to a ShinobiGridView.

abstract void restoreState(Parcelable state)
Called by the ShinobiGridView during the recreation of this Column to restore its state to what it was, prior to its destruction.
abstract void saveState(Parcelable state)
Called by the ShinobiGridView to retrieve instance state of this Column before it is destroyed, so that it can be restored at some time in the future.

Public Methods

public abstract Parcelable createParcelable ()

Creates a Parcelable which may be used to save the state of this Column. This method is typically used by the ShinobiGridView prior to the destruction of this Column.

Returns
  • the Parcelable which may be used to save the state of this Column

public abstract int getHeaderItemViewType ()

Returns the item view type for the header of the Column this ColumnSpec describes. If hasHeader() returns false this method will not be called.

Returns
  • the item view type for the header of the Column this ColumnSpec describes

public abstract int getItemViewType (int rowIndex)

Returns the item view type for the given rowIndex in the grid.

Parameters
rowIndex the zero-based index of the row in the grid that the item being bound to the given holder is on
Returns
  • the item view type for the item at the given rowIndex in the grid

public abstract Integer getWidth ()

Gets the width, in pixels which the Column which this ColumnSpec defines should adopt, the next time it is laid out.

Note: by returning a value other than null any default or minimum column width values set on the ShinobiGridView, for the Column which this ColumnSpec defines are overridden. Conversely, returning a null value will result in the width of the Column which this ColumnSpec defines, being set to the defaultColumnWidth, or minimumColumnWidth, if set. If neither are set, then a column width which allows the ShinobiGridView to use all available space will be used.

Returns
  • the width, in pixels which the Column which this ColumnSpec defines should adopt, the next time it is laid out

public abstract boolean hasHeader ()

Returns whether the Column this ColumnSpec describes has a header or not. If at least one Column in a ShinobiGridView has a header then a header row will be displayed.

Returns
  • whether the Column this ColumnSpec describes has a header or not

public abstract void initialize (Column.Callback callback)

Called when the Column is created, this method gives this ColumnSpec an opportunity to hold a reference to a callback object that provides controlled access to the Column via a number of useful methods.

Parameters
callback the Callback into the Column which contains a number of useful methods

public abstract void onBindHeaderViewHolder (RecyclerView.ViewHolder holder)

Updates the contents of the item view for the header of the Column this ColumnSpec describes. The provided ViewHolder can be cast to the more specific ViewHolder subclass that is being used for the Column's header, allowing its contents to be updated. If hasHeader() returns false this method will not be called.

Parameters
holder the ViewHolder containing the item view for the Column's header

public abstract void onBindViewHolder (RecyclerView.ViewHolder holder, int rowIndex)

Updates the contents of the item view to reflect the given rowIndex. The provided RecyclerView.ViewHolder will be suitable for the given rowIndex and therefore can be cast to a more specific ViewHolder subclass to allow the updating of the item view inside the holder.

Parameters
holder the ViewHolder containing an item view that is suitable for the given position
rowIndex the zero-based index of the row in the grid that the item being bound to the given holder is on

public abstract void onColumnAdded (Context context)

Notifies this ColumnSpec that the Column it belongs to has been added to a ShinobiGridView. The current Context is passed in allowing the retrieval of attributes in the theme that has been applied to the grid.

Parameters
context the current context of the grid the Column has been added to providing access to attributes in the current theme

public abstract void restoreState (Parcelable state)

Called by the ShinobiGridView during the recreation of this Column to restore its state to what it was, prior to its destruction.

This method provides a convenient place restore custom state, such as width.

Parameters
state the Parcelable containing the state of this Column

public abstract void saveState (Parcelable state)

Called by the ShinobiGridView to retrieve instance state of this Column before it is destroyed, so that it can be restored at some time in the future.

This method provides a convenient place save custom state, such as width.

Parameters
state the Parcelable containing the state of this Column