public interface

HasGridBehavior

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

Class Overview

Describes grid-specific behavior.

The GridRecyclerView implements the HasGridBehavior interface and thus it describes a set of behavior distinct from the standard RecyclerView of which the GridRecyclerView is a subclass.

Custom implementations of this interface are not supported nor should they be necessary.

Summary

Public Methods
abstract int getColumnIndexForPosition(int position)

Returns the index of the Column that corresponds to the given position.

abstract int[] getHiddenItemPositions()

Returns the positions of all currently hidden items within this HasGridBehavior.

abstract int getPosition(int columnIndex, int rowIndex)

Returns the position that corresponds to the given column index and row index.

abstract void getRelativeParentRect(Rect outRect)

Returns a Rect that describes the bounds of this HasGridBehavior's parent.

abstract int getRowIndexForPosition(int position)

Returns the index of the row that corresponds to the given position.

abstract int[] getSelectedItemPositions()

Returns the positions of all currently selected items within this HasGridBehavior.

abstract boolean isItemSelected(int position)

Returns whether the item at the given position is selected.

abstract boolean isItemVisible(int itemPosition)

Returns the visibility status of the item at the given position.

abstract void notifyRowRangeChanged(int startRowIndex, int rowCount)

Notify any registered observers that the items on each row within the given range have changed.

abstract void setItemSelected(int position, boolean selected)

Sets the selection state of the item at the given position.

abstract void setItemVisible(int itemPosition, boolean visible)

Sets the visibility of the item at the given position.

Public Methods

public abstract int getColumnIndexForPosition (int position)

Returns the index of the Column that corresponds to the given position. This method helps translate between adapter positions, which are a android.support.v7.widget.RecyclerView concept, and row and column indices which are specific to the ShinobiGridView. This can be useful when creating custom android.support.v7.widget.RecyclerView.OnItemTouchListeners.

If position does not map to a Column, for example if position is out of the range of all the valid positions, a value of -1 will be returned.

Parameters
position the position to query
Returns
  • the index of the Column that corresponds to the given position, or -1 if position does not map to a Column

public abstract int[] getHiddenItemPositions ()

Returns the positions of all currently hidden items within this HasGridBehavior. A position can be converted to a row and column index using getRowIndexForPosition(int) and getColumnIndexForPosition(int) respectively. Modifying the returned array will have no effect on the hidden items within the grid.

Returns
  • the positions of all currently hidden items

public abstract int getPosition (int columnIndex, int rowIndex)

Returns the position that corresponds to the given column index and row index. This method helps translate between row and column indices, which are specific to the ShinobiGridView, and adapter positions which are a android.support.v7.widget.RecyclerView concept.

If columnIndex and rowIndex do not map to a valid position, for example if the column index is greater than the number of columns present, a value of -1 will be returned.

Parameters
columnIndex the index of the column the item whose position is being queried is in
rowIndex the index of the row the item whose position is being queried is in
Returns
  • the position for the item that is in the given column and row

public abstract void getRelativeParentRect (Rect outRect)

Returns a Rect that describes the bounds of this HasGridBehavior's parent. Importantly, this Rect will be relative to this HasGridBehavior. So, for example, if this HasGridBehavior relates to the GridRecyclerView holding the data items of the grid, the top value of this Rect may be negative if the grid has a header row.

Parameters
outRect filled with the bounds of this HasGridBehavior's parent

public abstract int getRowIndexForPosition (int position)

Returns the index of the row that corresponds to the given position. This method helps translate between adapter positions, which are a android.support.v7.widget.RecyclerView concept, and row and column indices which are specific to the ShinobiGridView. This can be useful when creating custom android.support.v7.widget.RecyclerView.OnItemTouchListeners.

If position does not map to a row, for example if position is out of the range of all the valid positions, a value of -1 will be returned.

Parameters
position the position to query
Returns
  • the index of the row that corresponds to the given position, or -1 if position does not map to a row

public abstract int[] getSelectedItemPositions ()

Returns the positions of all currently selected items within this HasGridBehavior. A position can be converted to a row and column index using getRowIndexForPosition(int) and getColumnIndexForPosition(int) respectively. Modifying the returned array will have no effect on the selected items within the grid.

Returns
  • the positions of all currently selected items

public abstract boolean isItemSelected (int position)

Returns whether the item at the given position is selected. If no row or column exists in the grid for the given position then this will return false.

Parameters
position the position of the item
Returns
  • true if the item is selected, otherwise false

public abstract boolean isItemVisible (int itemPosition)

Returns the visibility status of the item at the given position. By default the visibility status of an item is true, which means the item can be displayed by the grid. An item with a visibility status set to false will not be shown on the grid but instead represented by a blank space at the position which was occupied by the item. If no row or column exists in the grid for the given position then this will return false.

Parameters
itemPosition the position of the item to check
Returns
  • true if the item visibility status is currently set to true, otherwise false

public abstract void notifyRowRangeChanged (int startRowIndex, int rowCount)

Notify any registered observers that the items on each row within the given range have changed.

Parameters
startRowIndex row index of the first row that has changed
rowCount number of rows that have changed, cannot be negative

public abstract void setItemSelected (int position, boolean selected)

Sets the selection state of the item at the given position. If no row or column exists in the grid for the given position then this will be ignored.

Parameters
position the position of the item in the grid
selected the selection state to be set on the item

public abstract void setItemVisible (int itemPosition, boolean visible)

Sets the visibility of the item at the given position. This method is particularly useful if you wish to hide an item on the grid, which is done by passing a false parameter. In this case the grid will display a blank space at the position which was occupied by the item. More precisely, the item placed here will be one that corresponds to the R.id.sg_hidden_item_view type registered with the ShinobiGridView. By default this is a transparent View but it is possible to register a different View to be used for hidden items (see registerItemViewHolderCreator(ItemViewHolderCreator)). If no row or column exists in the grid for this position then this will be ignored.

Parameters
itemPosition the position of the item
visible the visibility state to be set on the item