public final class

ShinobiGridView

extends ViewGroup
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ com.shinobicontrols.grids.core.ShinobiGridView

Class Overview

The ShinobiGridView is a highly customizable UI component that efficiently displays grid based information.

A theme to set various styling options can be applied to the grid by setting the sg_gridTheme attribute to an appropriate style resource. By default ShinobiGridTheme.Light is applied to the grid.

For the shinobigrids Trial Version, a valid license key must be set, using setTrialLicenseKey(String), before the grid renders otherwise an InvalidTrialLicenseException will be thrown. This is not necessary for purchased (non-trial) versions.

Summary

XML Attributes
Attribute Name Related Method Description
com.shinobicontrols.grids:sg_gridTheme  
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
ShinobiGridView(Context context)

Constructs a new ShinobiGridView.

ShinobiGridView(Context context, int gridThemeResourceId)

Constructs a new ShinobiGridView with the given GridTheme applied.

ShinobiGridView(Context context, AttributeSet attrs)

Constructs a new ShinobiGridView.

Public Methods
final boolean addColumn(Column column)

Adds the given Column to this ShinobiGridView.

final int getColumnCount()

Returns the number of columns in this ShinobiGridView.

final List<Column> getColumns()

Returns an unmodifiable List of all the Columns currently in this ShinobiGridView.

final GridRecyclerView getDataRecyclerView()

Returns the RecyclerView that holds the items for this ShinobiGridView's main body of data.

final Integer getDefaultColumnWidth()

Gets the width that all the columns in the grid will default to, in pixels.

final DataItemDecoration getDefaultDataItemDecoration()

Returns the DataItemDecoration that is added to the data RecyclerView by default.

final int getDefaultHeaderHeight()

Gets the height that the header row of the grid will default to, in pixels.

final HeaderItemDecoration getDefaultHeaderItemDecoration()

Returns the HeaderItemDecoration that is added to the header RecyclerView by default.

final ItemSingleTapDetector getDefaultItemSingleTapDetector()

Returns the ItemSingleTapDetector that is added to the data RecyclerView by default.

final Integer getDefaultRowHeight()

Gets the height that all the non-header rows in the grid will default to, in pixels.

final GridRecyclerView getHeaderRecyclerView()

Returns the RecyclerView that holds the items for this ShinobiGridView's header row.

final SelectionMode getItemSelectionMode()

Returns the SelectionMode that is currently applied when selecting items in the header and data RecyclerViews.

final ItemStateManager getItemStateManager()
Returns the ItemStateManager that handles the maintenance of state of the items in this ShinobiGridView.
final int getMinimumColumnWidth()

Returns the minimum width, in pixels, for the columns on the grid.

final int getMinimumRowHeight()

Returns the minimum height, in pixels, for the non-header rows on the grid.

final int getRowCount()

Returns the number of rows in this ShinobiGridView.

final boolean hasHeaderRow()

Returns whether this ShinobiGridView has a header row or not.

final void registerItemViewHolderCreator(ItemViewHolderCreator itemViewHolderCreator)

Registers an ItemViewHolderCreator with this ShinobiGridView.

final boolean removeColumn(int columnIndex)

Removes the Column at the given index from this ShinobiGridView.

final boolean removeColumn(Column column)

Removes the given Column from this ShinobiGridView.

final void reorderColumn(int columnIndex, int newColumnIndex)
Reorders the Column at columnIndex, placing it at newColumnIndex and moving the other columns in the ShinobiGridView accordingly.
final void setAdapterSpec(AdapterSpec adapterSpec)

Sets the AdapterSpec for this grid.

final void setDefaultColumnWidth(Integer defaultColumnWidth)

Sets the width that all the columns in the grid will default to.

final void setDefaultHeaderHeight(int defaultHeaderHeight)

Sets the height that the header row of the grid will default to.

final void setDefaultRowHeight(Integer defaultRowHeight)

Sets the height that all the non-header rows in the grid will default to.

final void setItemSelectionMode(SelectionMode selectionMode)

Sets the SelectionMode that will be applied when selecting items in the header and data RecyclerViews.

final void setItemStateManager(ItemStateManager itemStateManager)
Sets the ItemStateManager that is to be used to maintain the state of the items in this ShinobiGridView.
final void setMinimumColumnWidth(int minimumColumnWidth)

Sets the minimum width, in pixels, for the columns on the grid.

final void setMinimumRowHeight(int minimumRowHeight)

Sets the minimum height, in pixels, for the non-header rows on the grid.

final void setTrialLicenseKey(String trialLicenseKey)

Sets a trial license key for this grid.

final void unregisterItemViewHolderCreator(ItemViewHolderCreator itemViewHolderCreator)

Unregisters an ItemViewHolderCreator from this ShinobiGridView.

Protected Methods
void dispatchRestoreInstanceState(SparseArray<Parcelable> container)
void dispatchSaveInstanceState(SparseArray<Parcelable> container)
void onRestoreInstanceState(Parcelable state)
Parcelable onSaveInstanceState()
[Expand]
Inherited Methods
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

XML Attributes

com.shinobicontrols.grids:sg_gridTheme

Related Methods

Public Constructors

public ShinobiGridView (Context context)

Constructs a new ShinobiGridView. This should be used when creating the ShinobiGridView from code.

Parameters
context the Context the view is running in, through which it can access the current theme, resources, etc.

public ShinobiGridView (Context context, int gridThemeResourceId)

Constructs a new ShinobiGridView with the given GridTheme applied. This should be used when creating the ShinobiGridView from code.

Parameters
context the Context the view is running in, through which it can access the current theme, resources, etc.
gridThemeResourceId the GridTheme to apply to this ShinobiGridView

public ShinobiGridView (Context context, AttributeSet attrs)

Constructs a new ShinobiGridView. This is called when inflating the view from XML.

Parameters
context the Context the view is running in, through which it can access the current theme, resources, etc.
attrs the attributes of the XML tag that is inflating the view

Public Methods

public final boolean addColumn (Column column)

Adds the given Column to this ShinobiGridView. Columns allow you to display your data in the ShinobiGridView. Without any Columns the grid will be blank. A specific column can only be added to the grid once; attempting to add it again will have no effect and a value of false will be returned.

To create a Column you create a ColumnSpec which defines certain properties and behavior of the Column. You can also use one of the specs provided by the library, such as the TextColumnSpec.

Parameters
column the column to add to this ShinobiGridView
Returns
  • whether the column was successfully added to this ShinobiGridView

public final int getColumnCount ()

Returns the number of columns in this ShinobiGridView.

Returns

public final List<Column> getColumns ()

Returns an unmodifiable List of all the Columns currently in this ShinobiGridView.

Returns
  • an unmodifiable List of all Columns currently in this ShinobiGridView

public final GridRecyclerView getDataRecyclerView ()

Returns the RecyclerView that holds the items for this ShinobiGridView's main body of data.

Returns
  • the RecyclerView that holds the items for this ShinobiGridView's main body of data

public final Integer getDefaultColumnWidth ()

Gets the width that all the columns in the grid will default to, in pixels. By default this is set to null which means the grid will equally space all of its columns to fit the space it occupies.

Returns
  • the current default column width set on the grid

public final DataItemDecoration getDefaultDataItemDecoration ()

Returns the DataItemDecoration that is added to the data RecyclerView by default. Primarily this method is used to obtain a reference to the item decoration so that it can be removed via the removeItemDecoration(RecyclerView.ItemDecoration) method.

Returns

public final int getDefaultHeaderHeight ()

Gets the height that the header row of the grid will default to, in pixels. By default this is set to 50dp.

Returns
  • the default height, in pixels, for the header row of the grid

public final HeaderItemDecoration getDefaultHeaderItemDecoration ()

Returns the HeaderItemDecoration that is added to the header RecyclerView by default. Primarily this method is used to obtain a reference to the item decoration so that it can be removed via the removeItemDecoration(RecyclerView.ItemDecoration) method.

Returns

public final ItemSingleTapDetector getDefaultItemSingleTapDetector ()

Returns the ItemSingleTapDetector that is added to the data RecyclerView by default. Primarily this method is used to obtain a reference to the ItemSingleTapDetector so that its ItemSingleTapDetector.Callback can be overridden or removed by the user.

Returns

public final Integer getDefaultRowHeight ()

Gets the height that all the non-header rows in the grid will default to, in pixels. By default this is set to null which means the grid will equally space all of its rows to fit the space it occupies.

Returns
  • the default height, in pixels, for the non-header rows on the grid

public final GridRecyclerView getHeaderRecyclerView ()

Returns the RecyclerView that holds the items for this ShinobiGridView's header row.

Returns
  • the RecyclerView that holds the items for this ShinobiGridView's header row

public final SelectionMode getItemSelectionMode ()

Returns the SelectionMode that is currently applied when selecting items in the header and data RecyclerViews. If this has been set to null then calls to setItemSelected(int, boolean) do not have any effect.

Returns

public final ItemStateManager getItemStateManager ()

Returns the ItemStateManager that handles the maintenance of state of the items in this ShinobiGridView. Specifically, it updates the selection and hidden states of items in the grid after certain events have occurred, such as the reordering of columns. May be null.

Returns

public final int getMinimumColumnWidth ()

Returns the minimum width, in pixels, for the columns on the grid. By default this is set to 0. The columns will fill the available space in the grid if the minimum column width is too small to be applicable.

If a default column width has been set on the grid this will take precedence over the minimum column width.

Returns
  • the minimum width, in pixels, for the columns on the grid

public final int getMinimumRowHeight ()

Returns the minimum height, in pixels, for the non-header rows on the grid. By default this is set to 0. The rows will fill the available space in the grid if the minimum row height is too small to be applicable.

If a default row height has been set on the grid this will take precedence over the minimum row height.

Returns
  • the minimum height, in pixels, for the non-header rows on the grid

public final int getRowCount ()

Returns the number of rows in this ShinobiGridView. This value only refers to rows of data items and does not include the header row.

Returns

public final boolean hasHeaderRow ()

Returns whether this ShinobiGridView has a header row or not. If at least one of its Columns has a header then this will be true.

Returns

public final void registerItemViewHolderCreator (ItemViewHolderCreator itemViewHolderCreator)

Registers an ItemViewHolderCreator with this ShinobiGridView. An ItemViewHolderCreator maps an itemViewType, which is just a unique int identifier, to a method of creating a corresponding android.support.v7.widget.RecyclerView.ViewHolder.

Columns can define, based on the current item position, what itemViewType a specific cell should be. This allows a Column to contain multiple types of android.view.Views. A number of ItemViewHolderCreators have been pre-defined and pre-registered by the library - see the R.id class a list of corresponding itemViewType identifiers.

Registering an ItemViewTypeCreator that returns the same itemViewType as an existing ItemViewTypeCreator will overwrite the existing one with the new one.

Parameters
itemViewHolderCreator the ItemViewHolderCreator to register with the grid

public final boolean removeColumn (int columnIndex)

Removes the Column at the given index from this ShinobiGridView. Columns allow you to display your data in the ShinobiGridView. Without any Columns the grid will be blank.

You may find the getColumns() method helpful for obtaining a valid Column index.

If you provide a negative or invalid Column index to this method, such as that of a Column which does not exist on the ShinobiGridView, the request to remove the Column will be ignored. In this case this method will return false.

Parameters
columnIndex the index of the column to remove from this ShinobiGridView, which is zero based
Returns
  • whether the column was successfully removed from this ShinobiGridView

public final boolean removeColumn (Column column)

Removes the given Column from this ShinobiGridView. Columns allow you to display your data in the ShinobiGridView. Without any Columns the grid will be blank.

To obtain a valid Column reference, first obtain a List of Column references by calling the method getColumns().

If you provide a null or invalid Column reference to this method, such as that of a Column which does not exist on the ShinobiGridView, the request to remove the Column will be ignored. In this case this method will return false.

Parameters
column the column to remove from this ShinobiGridView
Returns
  • whether the column was successfully removed from this ShinobiGridView

public final void reorderColumn (int columnIndex, int newColumnIndex)

Reorders the Column at columnIndex, placing it at newColumnIndex and moving the other columns in the ShinobiGridView accordingly. If either columnIndex or newColumnIndex are negative, or greater than or equal to the number of columns on this ShinobiGridView no action will be taken.

Parameters
columnIndex the index of the Column to be reordered
newColumnIndex the index that the Column being reordered will be moved to

public final void setAdapterSpec (AdapterSpec adapterSpec)

Sets the AdapterSpec for this grid. The AdapterSpec defines certain properties of a grid, such as the number of rows it will contain.

It is not possible to set a null AdapterSpec on the grid; attempting to do so will result in an java.lang.IllegalArgumentException being thrown.

Parameters
adapterSpec the AdapterSpec that describes this grid

public final void setDefaultColumnWidth (Integer defaultColumnWidth)

Sets the width that all the columns in the grid will default to.

To revert back to the system default, which is to equally space all of the columns to fit the space the grid occupies, set this value to null.

Parameters
defaultColumnWidth the value representing the default column width, may be null

public final void setDefaultHeaderHeight (int defaultHeaderHeight)

Sets the height that the header row of the grid will default to.

To revert back to the initial height set this value to 50dp.

Negative values passed to this method will be ignored and as such will have no visible effect on the grid.

Parameters
defaultHeaderHeight the default row height, in pixels, which the header row of the grid should adopt

public final void setDefaultRowHeight (Integer defaultRowHeight)

Sets the height that all the non-header rows in the grid will default to.

To revert back to the system default, which is to equally space all of the rows to fit the space the grid occupies, set this value to null.

Negative values passed to this method will be ignored and as such will have no visible effect on the grid.

Parameters
defaultRowHeight the default row height, in pixels, which the non-header rows of the grid should adopt, may be null

public final void setItemSelectionMode (SelectionMode selectionMode)

Sets the SelectionMode that will be applied when selecting items in the header and data RecyclerViews. If this is set to null then calls to setItemSelected(int, boolean) will not have any effect.

When the SelectionMode is changed the grid makes no attempt to validate the current selection state of its items.

Parameters
selectionMode the SelectionMode that will be applied when selecting items

public final void setItemStateManager (ItemStateManager itemStateManager)

Sets the ItemStateManager that is to be used to maintain the state of the items in this ShinobiGridView. Specifically, it updates the selection and hidden states of items in the grid after certain events have occurred, such as the reordering of columns. May be set to null if you do not wish for any maintenance of item state to be performed.

Parameters
itemStateManager the ItemStateManager that is to be used to maintain the state of the items in this ShinobiGridView, may be null

public final void setMinimumColumnWidth (int minimumColumnWidth)

Sets the minimum width, in pixels, for the columns on the grid. By default this is set to 0. The columns will fill the available space in the grid if the minimum column width is too small to be applicable.

If a default column width has been set on the grid this will take precedence over the minimum column width.

Parameters
minimumColumnWidth the minimum width, in pixels which the columns of the grid should adopt.

public final void setMinimumRowHeight (int minimumRowHeight)

Sets the minimum height, in pixels, for the non-header rows on the grid. By default this is set to 0. The rows will fill the available space in the grid if the minimum row height is too small to be applicable.

If a default row height has been set on the grid this will take precedence over the minimum row height.

Negative values passed to this method will be ignored and as such will have no visible effect on the grid.

Parameters
minimumRowHeight the minimum row height, in pixels, which the non-header rows of the grid should adopt

public final void setTrialLicenseKey (String trialLicenseKey)

Sets a trial license key for this grid.

For the trial version of shinobigrids, a valid trial license key must be set before the grid will render. This is not necessary for any purchased (non-trial) version.

Parameters
trialLicenseKey the license key used to validate the trial version

public final void unregisterItemViewHolderCreator (ItemViewHolderCreator itemViewHolderCreator)

Unregisters an ItemViewHolderCreator from this ShinobiGridView. You must ensure any columns that relied on the removed ItemViewHolderCreator to create ViewHolders for their cells have been removed from the grid before it is rendered again.

Parameters
itemViewHolderCreator the ItemViewHolderCreator to unregister from the grid

Protected Methods

protected void dispatchRestoreInstanceState (SparseArray<Parcelable> container)

protected void dispatchSaveInstanceState (SparseArray<Parcelable> container)

protected void onRestoreInstanceState (Parcelable state)

protected Parcelable onSaveInstanceState ()