public final class

RowReorderDetector

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

Class Overview

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

It is given an RowReorderDetector.OnRowReorderListener which can be used to hook into specific parts of the reorder event allowing, for example, a backing data store to be reordered in line with the user gesture.

This RowReorderDetector will not perform any reordering actions on your data; it simply informs its callback of any changes in the rows' position. Therefore, any such reordering operations should be done by the callback.

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

Summary

Nested Classes
interface RowReorderDetector.OnRowReorderListener

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

Public Constructors
RowReorderDetector()
Public Methods
void addOnRowReorderListener(RowReorderDetector.OnRowReorderListener onRowReorderListener)

Adds an RowReorderDetector.OnRowReorderListener to this RowReorderDetector's list of listeners be invoked when a row 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 removeOnRowReorderListener(RowReorderDetector.OnRowReorderListener onRowReorderListener)

Removes the given RowReorderDetector.OnRowReorderListener from this RowReorderDetector's list of listeners be invoked when a row 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 RowReorderDetector ()

Public Methods

public void addOnRowReorderListener (RowReorderDetector.OnRowReorderListener onRowReorderListener)

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

Parameters
onRowReorderListener the RowReorderDetector.OnRowReorderListener to be added to the list of listeners to be invoked when a row 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 removeOnRowReorderListener (RowReorderDetector.OnRowReorderListener onRowReorderListener)

Removes the given RowReorderDetector.OnRowReorderListener from this RowReorderDetector's list of listeners be invoked when a row on the grid has been reordered.

Parameters
onRowReorderListener the RowReorderDetector.OnRowReorderListener to be removed from the list of listeners to be invoked when a row on the grid has been reordered