java.lang.Object
   ↳ com.shinobicontrols.grids.supplement.ItemStateManager

Class Overview

Convenience class to update the positions, of hidden and selected items on the ShinobiGridView following a row or column reorder operation.

The ItemStateManager implements both the RowReorderDetector.OnRowReorderListener and ColumnReorderDetector.OnColumnReorderListener interfaces. In the onRowReorderStarted(int, GridRecyclerView) and onColumnReorderStarted(int, GridRecyclerView) methods it stores the existing positions of selected and hidden items in both the header and data GridRecyclerView. In the onRowReorderEnded(int, int, GridRecyclerView) and onColumnReorderEnded(int, int, GridRecyclerView) methods it will calculate the updated positions based on the row or column reorder and apply these to the ShinobiGridView.

In most cases an instance of the ItemStateManager should be added to a VisualRowReorderer and/or a VisualColumnReorderer to ensure the reinstating of selected and hidden items is performed at the correct time. Alternatively, if you are not providing any form of visual feedback for a reorder gesture an ItemStateManager can be added directly to a RowReorderDetector or a ColumnReorderDetector.

This class is one of many that are used by the RowColumnReorderManager to enable intuitive row and column reordering on the ShinobiGridView. In general, the RowColumnReorderManager provides a more convenient way of achieving this. However, for more specialized situations this class can be leveraged in conjunction with other classes to provide the same item state preserving behavior.

Summary

Public Constructors
ItemStateManager()

Constructs a new ItemStateManager.

Public Methods
void onColumnIndexChanged(int columnIndex, int fromColumnIndex, int toColumnIndex, GridRecyclerView gridRecyclerView)

Currently not used.

void onColumnReorderCancelled(int columnIndex, GridRecyclerView gridRecyclerView)

Tidies up any stored state once the reorder event is cancelled.

void onColumnReorderEnded(int columnIndex, int endColumnIndex, GridRecyclerView gridRecyclerView)

Calculates the updated positions of selected and hidden items, including hidden header items, and applies them to the ShinobiGridView thus preserving the selected and hidden items across the reorder event.

void onColumnReorderStarted(int columnIndex, GridRecyclerView gridRecyclerView)

Stores the positions of the selected and hidden items in the ShinobiGridView.

void onRowIndexChanged(int rowIndex, int fromRowIndex, int toRowIndex, GridRecyclerView gridRecyclerView)

Currently not used.

void onRowReorderCancelled(int rowIndex, GridRecyclerView gridRecyclerView)

Tidies up any stored state once the reorder event is cancelled.

void onRowReorderEnded(int rowIndex, int endRowIndex, GridRecyclerView gridRecyclerView)

Calculates the updated positions of selected and hidden items, including hidden header items, and applies them to the ShinobiGridView thus preserving the selected and hidden items across the reorder event.

void onRowReorderStarted(int rowIndex, GridRecyclerView gridRecyclerView)

Stores the positions of the selected and hidden items in the ShinobiGridView.

[Expand]
Inherited Methods
From class java.lang.Object
From interface com.shinobicontrols.grids.supplement.ColumnReorderDetector.OnColumnReorderListener
From interface com.shinobicontrols.grids.supplement.RowReorderDetector.OnRowReorderListener

Public Constructors

public ItemStateManager ()

Constructs a new ItemStateManager.

Public Methods

public void onColumnIndexChanged (int columnIndex, int fromColumnIndex, int toColumnIndex, GridRecyclerView gridRecyclerView)

Currently not used.

Parameters
columnIndex the index of the column that is being reordered
fromColumnIndex the index that the column being reordered has moved from due to dragging
toColumnIndex the index that the column being reordered has moved to due to dragging
gridRecyclerView the GridRecyclerView on which the reordering event was initiated

public void onColumnReorderCancelled (int columnIndex, GridRecyclerView gridRecyclerView)

Tidies up any stored state once the reorder event is cancelled.

Parameters
columnIndex the index of the column that was being reordered
gridRecyclerView the GridRecyclerView on which the reordering event was initiated

public void onColumnReorderEnded (int columnIndex, int endColumnIndex, GridRecyclerView gridRecyclerView)

Calculates the updated positions of selected and hidden items, including hidden header items, and applies them to the ShinobiGridView thus preserving the selected and hidden items across the reorder event.

Parameters
columnIndex the index of the column that is being reordered
endColumnIndex the index that the column being reordered has moved to at the end of the reorder event
gridRecyclerView the GridRecyclerView on which the reordering event was initiated

public void onColumnReorderStarted (int columnIndex, GridRecyclerView gridRecyclerView)

Stores the positions of the selected and hidden items in the ShinobiGridView. This includes any hidden items in the header row.

Parameters
columnIndex the index of the column that is being reordered
gridRecyclerView the GridRecyclerView on which the reordering event was initiated

public void onRowIndexChanged (int rowIndex, int fromRowIndex, int toRowIndex, GridRecyclerView gridRecyclerView)

Currently not used.

Parameters
rowIndex the index of the row that is being reordered
fromRowIndex the index that the row being reordered has moved from due to dragging
toRowIndex the index that the row being reordered has moved to due to dragging
gridRecyclerView the GridRecyclerView on which the reordering event was initiated

public void onRowReorderCancelled (int rowIndex, GridRecyclerView gridRecyclerView)

Tidies up any stored state once the reorder event is cancelled.

Parameters
rowIndex the index of the row that was being reordered
gridRecyclerView the GridRecyclerView on which the reordering event was initiated

public void onRowReorderEnded (int rowIndex, int endRowIndex, GridRecyclerView gridRecyclerView)

Calculates the updated positions of selected and hidden items, including hidden header items, and applies them to the ShinobiGridView thus preserving the selected and hidden items across the reorder event.

Parameters
rowIndex the index of the row that is being reordered
endRowIndex the index that the row being reordered has moved to at the end of the reorder event
gridRecyclerView the GridRecyclerView on which the reordering event was initiated

public void onRowReorderStarted (int rowIndex, GridRecyclerView gridRecyclerView)

Stores the positions of the selected and hidden items in the ShinobiGridView. This includes any hidden items in the header row.

Parameters
rowIndex the index of the row that is being reordered
gridRecyclerView the GridRecyclerView on which the reordering event was initiated