public class

TextColumnSpec

extends Object
implements ColumnSpec OnStyleChangedListener
java.lang.Object
   ↳ com.shinobicontrols.grids.supplement.TextColumnSpec

Class Overview

A convenience ColumnSpec that deals with textual data and places it in android.widget.TextViews. A PropertyBinder, parametrized by java.lang.CharSequence, is required in order to provide the text for the TextViews.

By default it creates several styles and sets itself as a listener for changes to those styles, refreshing the grid each time a change is made. New style objects can be set on the grid and will cause an immediate redraw but this TextColumnSpec must be set as the styles' OnStyleChangedListener for any further changes to have any effect.

Summary

Fields
protected Column.Callback callback

The Callback providing controlled access to the Column this ColumnSpec describes.

Public Constructors
TextColumnSpec(PropertyBinder<CharSequence> propertyBinder)

Creates a new TextColumnSpec with the given PropertyBinder, which provides the text for the onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder, int) method to place into the TextViews.

TextColumnSpec(CharSequence columnTitle, PropertyBinder<CharSequence> propertyBinder)

Creates a new TextColumnSpec with the given title and PropertyBinder, which provides the text for the onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder, int) method to place into the TextViews.

Public Methods
TextColumnStyle getAlternateStyle()

Returns the TextColumnStyle that is used to style the TextViews of the alternate rows within the Column this ColumnSpec relates to.

CharSequence getColumnTitle()

Returns the title given to this ColumnSpec.

TextColumnStyle getDefaultStyle()

Returns the TextColumnStyle that is used to style the TextViews within the Column this ColumnSpec relates to.

int getHeaderItemViewType()

Returns the itemViewType for the header of this TextColumnSpec - this is sg_header_text_view.

TextColumnStyle getHeaderStyle()

Returns the TextColumnStyle that is used to style the TextViews of the header within the Column this ColumnSpec relates to.

int getItemViewType(int rowIndex)

Returns the itemViewType for this TextColumnSpec - this is sg_text_view and is applicable for every row in the column.

PropertyBinder<CharSequence> getPropertyBinder()

Returns the PropertyBinder for this TextColumnSpec.

TextColumnStyle getSelectedStyle()

Returns the TextColumnStyle that is used to style the TextViews of the selected items within the Column this ColumnSpec relates to.

boolean hasHeader()

Returns true if this ColumnSpec was given a non-null columnTitle when instantiated, false otherwise.

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.

void onBindHeaderViewHolder(RecyclerView.ViewHolder holder)

Binds the columnTitle for this TextColumnSpec to the TextView inside a HeaderTextViewHolder.

void onBindViewHolder(RecyclerView.ViewHolder holder, int rowIndex)

Binds the CharSequence returned from this TextColumnSpec's PropertyBinder to the TextView inside a TextViewHolder.

void onColumnAdded(Context context)

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

void onStyleChanged()

Called when the style has changed.

void setAlternateStyle(TextColumnStyle alternateStyle)

Sets the style for each item on the alternate rows within this ColumnSpec.

void setDefaultStyle(TextColumnStyle defaultStyle)

Sets the style for each item on the even rows within this ColumnSpec.

void setHeaderStyle(TextColumnStyle headerStyle)

Sets the style for the item on the header row within this ColumnSpec.

void setSelectedStyle(TextColumnStyle selectedStyle)

Sets the style for each selected item within this ColumnSpec.

[Expand]
Inherited Methods
From class java.lang.Object
From interface com.shinobicontrols.grids.core.ColumnSpec
From interface com.shinobicontrols.grids.supplement.OnStyleChangedListener

Fields

protected Column.Callback callback

The Callback providing controlled access to the Column this ColumnSpec describes. It has a number of useful methods including the notifyDataSetChanged() method which can be used to notify the ShinobiGridView that the visual appearance of the items in the Column this ColumnSpec describes has changed.

This reference is set in the initialize(com.shinobicontrols.grids.core.Column.Callback) method and so when subclassing this TextColumnSpec, if you do not call the super implementation of the initialize() method this will be null.

Public Constructors

public TextColumnSpec (PropertyBinder<CharSequence> propertyBinder)

Creates a new TextColumnSpec with the given PropertyBinder, which provides the text for the onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder, int) method to place into the TextViews.

Parameters
propertyBinder the PropertyBinder that provides the text to be bound to the TextViews given to the Column

public TextColumnSpec (CharSequence columnTitle, PropertyBinder<CharSequence> propertyBinder)

Creates a new TextColumnSpec with the given title and PropertyBinder, which provides the text for the onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder, int) method to place into the TextViews.

Parameters
columnTitle the title for this Column
propertyBinder the PropertyBinder that provides the text to be bound to the TextViews given to the Column

Public Methods

public TextColumnStyle getAlternateStyle ()

Returns the TextColumnStyle that is used to style the TextViews of the alternate rows within the Column this ColumnSpec relates to.

Returns
  • the TextColumnStyle that is used to style the TextViews of the alternate rows

public CharSequence getColumnTitle ()

Returns the title given to this ColumnSpec. May be null.

Returns
  • the title for this ColumnSpec, may be null

public TextColumnStyle getDefaultStyle ()

Returns the TextColumnStyle that is used to style the TextViews within the Column this ColumnSpec relates to.

Returns

public int getHeaderItemViewType ()

Returns the itemViewType for the header of this TextColumnSpec - this is sg_header_text_view.

Returns
  • the itemViewType for the header of this TextColumnSpec

public TextColumnStyle getHeaderStyle ()

Returns the TextColumnStyle that is used to style the TextViews of the header within the Column this ColumnSpec relates to.

Returns

public int getItemViewType (int rowIndex)

Returns the itemViewType for this TextColumnSpec - this is sg_text_view and is applicable for every row in the column.

Parameters
rowIndex the zero-based index of the row in the grid that the item being bound to the given holder is on, as the same itemViewType is returned for every row in this TextColumnSpec the rowIndex is not used
Returns
  • the itemViewType for this TextColumnSpec

public PropertyBinder<CharSequence> getPropertyBinder ()

Returns the PropertyBinder for this TextColumnSpec. This provides the text for the onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder, int) method to place into the TextViews.

Returns
  • the PropertyBinder for this TextColumnSpec

public TextColumnStyle getSelectedStyle ()

Returns the TextColumnStyle that is used to style the TextViews of the selected items within the Column this ColumnSpec relates to.

Returns
  • the TextColumnStyle that is used to style the TextViews of the selected items

public boolean hasHeader ()

Returns true if this ColumnSpec was given a non-null columnTitle when instantiated, false otherwise.

Returns
  • true if this ColumnSpec was given a non-null columnTitle when instantiated, false otherwise

public 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 void onBindHeaderViewHolder (RecyclerView.ViewHolder holder)

Binds the columnTitle for this TextColumnSpec to the TextView inside a HeaderTextViewHolder.

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

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

Binds the CharSequence returned from this TextColumnSpec's PropertyBinder to the TextView inside a TextViewHolder.

Parameters
holder the ViewHolder containing an item view that is suitable for the given rowIndex - this can be safely cast to a TextViewHolder
rowIndex the zero-based index of the row in the grid that the item being bound to the given holder is on

public 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 void onStyleChanged ()

Called when the style has changed.

public void setAlternateStyle (TextColumnStyle alternateStyle)

Sets the style for each item on the alternate rows within this ColumnSpec. If the Column this ColumnSpec defines is added to the grid then this setting the style will cause an automatic redraw. For subsequent changes to the style to cause the grid to redraw then this ColumnSpec needs to be added as a listener to the style using the setOnStyleChangedListener(OnStyleChangedListener) method.

It is not possible to set a null TextColumnStyle on this TextColumnSpec; attempting to do so will result in an java.lang.IllegalArgumentException being thrown.

Parameters
alternateStyle the style for each item on the alternate rows within this ColumnSpec

public void setDefaultStyle (TextColumnStyle defaultStyle)

Sets the style for each item on the even rows within this ColumnSpec. If the Column this ColumnSpec defines is added to the grid then this setting the style will cause an automatic redraw. For subsequent changes to the style to cause the grid to redraw then this ColumnSpec needs to be added as a listener to the style using the setOnStyleChangedListener(OnStyleChangedListener) method.

It is not possible to set a null TextColumnStyle on this TextColumnSpec; attempting to do so will result in an java.lang.IllegalArgumentException being thrown.

Parameters
defaultStyle the style for each item on the even rows within this ColumnSpec

public void setHeaderStyle (TextColumnStyle headerStyle)

Sets the style for the item on the header row within this ColumnSpec. If the Column this ColumnSpec defines is added to the grid then this setting the style will cause an automatic redraw. For subsequent changes to the style to cause the grid to redraw then this ColumnSpec needs to be added as a listener to the style using the setOnStyleChangedListener(OnStyleChangedListener) method.

It is not possible to set a null TextColumnStyle on this TextColumnSpec; attempting to do so will result in an java.lang.IllegalArgumentException being thrown.

Parameters
headerStyle the style for the item on the header row within this ColumnSpec
See Also

public void setSelectedStyle (TextColumnStyle selectedStyle)

Sets the style for each selected item within this ColumnSpec. If the Column this ColumnSpec defines is added to the grid then this setting the style will cause an automatic redraw. For subsequent changes to the style to cause the grid to redraw then this ColumnSpec needs to be added as a listener to the style using the setOnStyleChangedListener(OnStyleChangedListener) method.

It is not possible to set a null TextColumnStyle on this TextColumnSpec; attempting to do so will result in an java.lang.IllegalArgumentException being thrown.

Parameters
selectedStyle the style for each selected item within this ColumnSpec