public final class

ColumnReorderDetector

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

Class Overview

An implementation of ItemDragDetector.OnItemDragListener that responds to drag gestures made on items within the grid, interpreting them as column reorder events. It considers column reordering from a reference point of the initial column the reordering event started on.

It is given an ColumnReorderDetector.OnColumnReorderListener which can be used to hook into specific parts of the reorder event allowing, for example, the order of the columns within the ShinobiGridView's list of columns to be updated in line with the user gesture.

This ColumnReorderDetector will not perform any reordering actions on your data; it simply informs its callback of any changes in the columns' position. Therefore, any such reordering operations should be done by the callback. The ColumnReorderer is such a callback and is provided as a convenience.

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 column reordering behavior.

Summary

Nested Classes
interface ColumnReorderDetector.OnColumnReorderListener

Callback to be invoked when a column on the grid has been reordered. 

Public Constructors
ColumnReorderDetector()
Public Methods
void addOnColumnReorderListener(ColumnReorderDetector.OnColumnReorderListener onColumnReorderListener)

Adds an ColumnReorderDetector.OnColumnReorderListener to this ColumnReorderDetector's list of listeners be invoked when a column on the grid has been reordered.

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.

void removeOnColumnReorderListener(ColumnReorderDetector.OnColumnReorderListener onColumnReorderListener)

Removes the given ColumnReorderDetector.OnColumnReorderListener from this ColumnReorderDetector's list of listeners be invoked when a column on the grid has been reordered.

[Expand]
Inherited Methods
From class java.lang.Object
From interface com.shinobicontrols.grids.supplement.ItemDragDetector.OnItemDragListener

Public Constructors

public ColumnReorderDetector ()

Public Methods

public void addOnColumnReorderListener (ColumnReorderDetector.OnColumnReorderListener onColumnReorderListener)

Adds an ColumnReorderDetector.OnColumnReorderListener to this ColumnReorderDetector's list of listeners be invoked when a column on the grid has been reordered. Passing in null will throw an IllegalArgumentException.

Parameters
onColumnReorderListener the ColumnReorderDetector.OnColumnReorderListener to be added to the list of listeners to be invoked when a column on the grid has been reordered, cannot be null

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 void removeOnColumnReorderListener (ColumnReorderDetector.OnColumnReorderListener onColumnReorderListener)

Removes the given ColumnReorderDetector.OnColumnReorderListener from this ColumnReorderDetector's list of listeners be invoked when a column on the grid has been reordered.

Parameters
onColumnReorderListener the ColumnReorderDetector.OnColumnReorderListener to be removed from the list of listeners to be invoked when a column on the grid has been reordered