public class

VisualColumnReorderer

extends Object
implements ColumnReorderDetector.OnColumnReorderListener ItemDragDetector.OnItemDragListener
java.lang.Object
   ↳ com.shinobicontrols.grids.supplement.VisualColumnReorderer

Class Overview

Visualizes the reordering of columns within the ShinobiGridView. Specifically, the items in the column being reordered appear to be pulled out from the grid and move left or right in-sync with the user's finger until the gesture ends with the user lifting their finger.

This class is one of many that are used by the RowColumnReorderManager to enable 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 visual feedback during column reordering.

In order to provide this visual feedback, the VisualColumnReorderer must be added as a listener to both an ItemDragDetector and a ColumnReorderDetector.

This VisualColumnReorderer will only move the columns visually and will not update the ShinobiGridView's list of Column objects. This should be performed by a separate ColumnReorderDetector.OnColumnReorderListener such as the ColumnReorderer and can be added to this VisualColumnReorderer via the addOnColumnReorderListener(ColumnReorderDetector.OnColumnReorderListener) method.

By default the positions of selected and hidden items in the ShinobiGridView will not be updated to reflect the column reorder event. If you want to preserve selected and hidden item positions you can also add an ItemStateManager via the addOnColumnReorderListener(ColumnReorderDetector.OnColumnReorderListener) method.

By adding ColumnReorderDetector.OnColumnReorderListeners to this VisualColumnReorderer (instead of to the related ColumnReorderDetector) it will ensure that their callback methods are called at an appropriate time with respect to the visual feedback provided by this class.

Summary

Public Constructors
VisualColumnReorderer()

Constructs a new VisualColumnReorderer.

Public Methods
final void addOnColumnReorderListener(ColumnReorderDetector.OnColumnReorderListener listener)
void onColumnIndexChanged(int columnIndex, int fromColumnIndex, int toColumnIndex, GridRecyclerView gridRecyclerView)

The callback method to be invoked during a reorder event when a column has been moved enough for it to have been deemed to have changed places with an adjacent column.

void onColumnReorderCancelled(int columnIndex, GridRecyclerView gridRecyclerView)

The callback method to be invoked when a reorder event is cancelled.

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

The callback method to be invoked when a reorder event that has been performed on a column in the grid has ended.

void onColumnReorderStarted(int columnIndex, GridRecyclerView gridRecyclerView)

The callback method to be invoked when a reorder event is started on a column in the grid.

void onItemDrag(ItemDragDetector itemDragDetector, float x, float y, GridRecyclerView gridRecyclerView)

The callback method to be invoked while a drag gesture is being performed over items in the grid.

void onItemReleaseDrag(ItemDragDetector itemDragDetector, float x, float y, GridRecyclerView gridRecyclerView)

The callback method to be invoked when a drag gesture is completed.

void onItemStartDrag(ItemDragDetector itemDragDetector, float x, float y, GridRecyclerView gridRecyclerView)

The callback method to be invoked when the start of a drag gesture is performed on an item in the grid.

final void removeOnColumnReorderListener(ColumnReorderDetector.OnColumnReorderListener listener)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.shinobicontrols.grids.supplement.ColumnReorderDetector.OnColumnReorderListener
From interface com.shinobicontrols.grids.supplement.ItemDragDetector.OnItemDragListener

Public Constructors

public VisualColumnReorderer ()

Constructs a new VisualColumnReorderer.

Public Methods

public final void addOnColumnReorderListener (ColumnReorderDetector.OnColumnReorderListener listener)

Adds an ColumnReorderDetector.OnColumnReorderListener to this VisualColumnReorderer's list of listeners.

The onColumnReorderStarted(int, GridRecyclerView) method of each listener is guaranteed to be called before the visual feedback aspects of the column reorder event begins. Likewise, the onColumnReorderEnded(int, int, GridRecyclerView) method of each listener is guaranteed to be called after the visual feedback aspects of the column reorder event ends.

Parameters
listener the listener to add

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

The callback method to be invoked during a reorder event when a column has been moved enough for it to have been deemed to have changed places with an adjacent column. This will be called multiple times as the user drags their finger horizontally across the ShinobiGridView.

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)

The callback method to be invoked when a reorder event is cancelled. More specifically, this is when the column has been dragged to somewhere deemed invalid for the grid, for example, out of its bounds.

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)

The callback method to be invoked when a reorder event that has been performed on a column in the grid has ended. More specifically, this will be called at the end of a drag gesture, that is when the user lifts up their finger.

If at the end of the drag gesture the column has not been dragged far enough from its original position this method will be called with both parameters being the same value.

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)

The callback method to be invoked when a reorder event is started on a column in the grid. More specifically, this will be called when the user long presses a column. For the rest of the reorder event this column will be used as the reference point.

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

public void onItemDrag (ItemDragDetector itemDragDetector, float x, float y, GridRecyclerView gridRecyclerView)

The callback method to be invoked while a drag gesture is being performed over items in the grid. More specifically, this will be called at the end of each move gesture once a drag has been initiated by means of a long press. The given x and y values can be used with the getItemPosition(RecyclerView, float, float) method to obtain the position of the item in the ShinobiGridView at those co-ordinates.

To translate this position into a column index or a row index use the getColumnIndexForPosition(int) and getRowIndexForPosition(int) methods.

Parameters
itemDragDetector the ItemDragDetector detecting the drag gesture
x the x coordinate of the pointer at the end of the move event
y the y coordinate of the pointer at the end of the move event
gridRecyclerView the RecyclerView on which the drag gesture is performed

public void onItemReleaseDrag (ItemDragDetector itemDragDetector, float x, float y, GridRecyclerView gridRecyclerView)

The callback method to be invoked when a drag gesture is completed. More specifically, this will be called when the gesture is released at the end of a drag. The given x and y values can be used with the getItemPosition(RecyclerView, float, float) method to obtain the position of the item in the ShinobiGridView at those co-ordinates.

To translate this position into a column index or a row index use the getColumnIndexForPosition(int) and getRowIndexForPosition(int) methods.

Parameters
itemDragDetector the ItemDragDetector detecting the drag gesture
x the x coordinate of the pointer at the end of the drag gesture
y the y coordinate of the pointer at the end of the drag gesture
gridRecyclerView the GridRecyclerView on which the drag gesture is performed

public void onItemStartDrag (ItemDragDetector itemDragDetector, float x, float y, GridRecyclerView gridRecyclerView)

The callback method to be invoked when the start of a drag gesture is performed on an item in the grid. More specifically, this will be called on the end of a long press gesture. The given x and y values can be used with the getItemPosition(RecyclerView, float, float) method to obtain the position of the item in the ShinobiGridView at those co-ordinates.

To translate this position into a column index or a row index use the getColumnIndexForPosition(int) and getRowIndexForPosition(int) methods.

Parameters
itemDragDetector the ItemDragDetector detecting the drag gesture
x the x coordinate of the pointer at the start of the drag gesture
y the y coordinate of the pointer at the start of the drag gesture
gridRecyclerView the GridRecyclerView on which the drag gesture is performed

public final void removeOnColumnReorderListener (ColumnReorderDetector.OnColumnReorderListener listener)

Parameters
listener the listener to remove