public interface

ExpandableDraggableItemAdapter

com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableDraggableItemAdapter<GVH extends androidx.recyclerview.widget.RecyclerView.ViewHolder, CVH extends androidx.recyclerview.widget.RecyclerView.ViewHolder>

Summary

Public Methods
abstract boolean onCheckChildCanDrop(int draggingGroupPosition, int draggingChildPosition, int dropGroupPosition, int dropChildPosition)
Called while dragging in order to check whether the dragging item can be dropped to the specified position.
abstract boolean onCheckChildCanStartDrag(CVH holder, int groupPosition, int childPosition, int x, int y)
Called when user is attempt to drag the child item.
abstract boolean onCheckGroupCanDrop(int draggingGroupPosition, int dropGroupPosition)
Called while dragging in order to check whether the dragging item can be dropped to the specified position.
abstract boolean onCheckGroupCanStartDrag(GVH holder, int groupPosition, int x, int y)
Called when user is attempt to drag the group item.
abstract void onChildDragFinished(int fromGroupPosition, int fromChildPosition, int toGroupPosition, int toChildPosition, boolean result)
Callback method to be invoked when finished dragging a child item.
abstract void onChildDragStarted(int groupPosition, int childPosition)
Callback method to be invoked when started dragging a child item.
abstract ItemDraggableRange onGetChildItemDraggableRange(CVH holder, int groupPosition, int childPosition)
abstract ItemDraggableRange onGetGroupItemDraggableRange(GVH holder, int groupPosition)
abstract void onGroupDragFinished(int fromGroupPosition, int toGroupPosition, boolean result)
Callback method to be invoked when finished dragging a group item.
abstract void onGroupDragStarted(int groupPosition)
Callback method to be invoked when started dragging a group item.
abstract void onMoveChildItem(int fromGroupPosition, int fromChildPosition, int toGroupPosition, int toChildPosition)
Called when child item is moved.
abstract void onMoveGroupItem(int fromGroupPosition, int toGroupPosition)
Called when group item is moved.

Public Methods

public abstract boolean onCheckChildCanDrop (int draggingGroupPosition, int draggingChildPosition, int dropGroupPosition, int dropChildPosition)

Called while dragging in order to check whether the dragging item can be dropped to the specified position. NOTE: This method will be called when the checkCanDrop option is enabled by setCheckCanDropEnabled(boolean).

Parameters
draggingGroupPosition The group position of the currently dragging item.
draggingChildPosition The child position of the currently dragging item.
dropGroupPosition The group position to check whether the dragging item can be dropped or not.
dropChildPosition The child position to check whether the dragging item can be dropped or not.
Returns
  • Whether can be dropped to the specified position.

public abstract boolean onCheckChildCanStartDrag (CVH holder, int groupPosition, int childPosition, int x, int y)

Called when user is attempt to drag the child item.

Parameters
holder The child ViewHolder which is associated to item user is attempt to start dragging.
groupPosition Group position.
childPosition Child position.
x Touched X position. Relative from the itemView's top-left.
y Touched Y position. Relative from the itemView's top-left.
Returns
  • Whether can start dragging.

public abstract boolean onCheckGroupCanDrop (int draggingGroupPosition, int dropGroupPosition)

Called while dragging in order to check whether the dragging item can be dropped to the specified position. NOTE: This method will be called when the checkCanDrop option is enabled by setCheckCanDropEnabled(boolean).

Parameters
draggingGroupPosition The position of the currently dragging group item.
dropGroupPosition The position of a group item whether to check can be dropped or not.
Returns
  • Whether can be dropped to the specified position.

public abstract boolean onCheckGroupCanStartDrag (GVH holder, int groupPosition, int x, int y)

Called when user is attempt to drag the group item.

Parameters
holder The group ViewHolder which is associated to item user is attempt to start dragging.
groupPosition Group position.
x Touched X position. Relative from the itemView's top-left.
y Touched Y position. Relative from the itemView's top-left.
Returns
  • Whether can start dragging.

public abstract void onChildDragFinished (int fromGroupPosition, int fromChildPosition, int toGroupPosition, int toChildPosition, boolean result)

Callback method to be invoked when finished dragging a child item. Call the notifyDataSetChanged() method in this callback to get the same behavior with v0.10.x or before.

Parameters
fromGroupPosition Previous group position of the item.
fromChildPosition Previous child position of the item.
toGroupPosition New group position of the item.
toChildPosition New child position of the item.
result Indicates whether the dragging operation was succeeded.

public abstract void onChildDragStarted (int groupPosition, int childPosition)

Callback method to be invoked when started dragging a child item. Call the notifyDataSetChanged() method in this callback to get the same behavior with v0.10.x or before.

Parameters
groupPosition The group position of the item.
childPosition The child position of the item.

public abstract ItemDraggableRange onGetChildItemDraggableRange (CVH holder, int groupPosition, int childPosition)

Parameters
holder The ViewHolder which is associated to item user is attempt to start dragging.
groupPosition Group position.
childPosition Child position.
Returns
  • null: no constraints (= new ItemDraggableRange(0, getGroupCount() - 1)), otherwise: the range specified item can be drag-sortable.

public abstract ItemDraggableRange onGetGroupItemDraggableRange (GVH holder, int groupPosition)

Parameters
holder The ViewHolder which is associated to item user is attempt to start dragging.
groupPosition Group position.
Returns
  • null: no constraints (= new ItemDraggableRange(0, getGroupCount() - 1)), otherwise: the range specified item can be drag-sortable.

public abstract void onGroupDragFinished (int fromGroupPosition, int toGroupPosition, boolean result)

Callback method to be invoked when finished dragging a group item. Call the notifyDataSetChanged() method in this callback to get the same behavior with v0.10.x or before.

Parameters
fromGroupPosition Previous position of the group item.
toGroupPosition New position of the group item.
result Indicates whether the dragging operation was succeeded.

public abstract void onGroupDragStarted (int groupPosition)

Callback method to be invoked when started dragging a group item. Call the notifyDataSetChanged() method in this callback to get the same behavior with v0.10.x or before.

Parameters
groupPosition The position of the group item.

public abstract void onMoveChildItem (int fromGroupPosition, int fromChildPosition, int toGroupPosition, int toChildPosition)

Called when child item is moved. Should apply the move operation result to data set.

Parameters
fromGroupPosition Previous group position of the item.
fromChildPosition Previous child position of the item.
toGroupPosition New group position of the item.
toChildPosition New child position of the item.

public abstract void onMoveGroupItem (int fromGroupPosition, int toGroupPosition)

Called when group item is moved. Should apply the move operation result to data set.

Parameters
fromGroupPosition Previous group position of the item.
toGroupPosition New group position of the item.