public class

RecyclerViewDragDropManager

extends Object
implements DraggableItemConstants
java.lang.Object
   ↳ com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager

Class Overview

Provides item drag & drop operation for android.support.v7.widget.RecyclerView

Summary

Nested Classes
@interface RecyclerViewDragDropManager.ItemMoveMode  
interface RecyclerViewDragDropManager.OnItemDragEventListener Used for listening item drag events  
Constants
int ITEM_MOVE_MODE_DEFAULT Default item move mode
int ITEM_MOVE_MODE_SWAP Swap two items between dragging item and the item under a finger (or mouse pointer)
[Expand]
Inherited Constants
From interface com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants
Fields
public static final Interpolator DEFAULT_ITEM_SETTLE_BACK_INTO_PLACE_ANIMATION_INTERPOLATOR Default interpolator used for "item settle back into place" animation
public static final Interpolator DEFAULT_SWAP_TARGET_TRANSITION_INTERPOLATOR Default interpolator used for "swap target transition"
Public Constructors
RecyclerViewDragDropManager()
Constructor.
Public Methods
void attachRecyclerView(RecyclerView rv)

Attaches android.support.v7.widget.RecyclerView instance.

void cancelDrag()
Cancel dragging.
Adapter createWrappedAdapter(Adapter adapter)
Create wrapped adapter.
float getDragEdgeScrollSpeed()
Gets drag edge scroll speed.
Interpolator getDragStartItemAlphaAnimationInterpolator()
Gets the interpolator which ise used for "drag start alpha" animation.
int getDragStartItemAnimationDuration()
Gets the duration of "drag start" animation.
Interpolator getDragStartItemRotationAnimationInterpolator()
Gets the interpolator which ise used for "drag start rotation" animation.
Interpolator getDragStartItemScaleAnimationInterpolator()
Gets the interpolator which ise used for "drag start scaling" animation.
float getDraggingItemAlpha()
Gets dragging item alpha.
float getDraggingItemRotation()
Gets dragging item rotation.
float getDraggingItemScale()
Gets dragging item scaling factor.
int getItemMoveMode()
Gets item move mode
int getItemSettleBackIntoPlaceAnimationDuration()
Gets the duration of "settle back into place" animation.
Interpolator getItemSettleBackIntoPlaceAnimationInterpolator()
Gets the interpolator which ise used for "settle back into place" animation.
RecyclerViewDragDropManager.OnItemDragEventListener getOnItemDragEventListener()
Gets OnItemDragEventListener listener
boolean isCheckCanDropEnabled()
Gets whether to use onCheckCanDrop(int, int).
boolean isDragging()
Indicates whether currently performing item dragging.
boolean isInitiateOnLongPressEnabled()
Returns whether dragging starts on a long press or not.
boolean isInitiateOnMoveEnabled()
Returns whether dragging starts on move motions.
boolean isInitiateOnTouchEnabled()
Returns whether dragging starts on touch the handle immediately.
boolean isReleased()
Indicates this manager instance has released or not.
void release()

Detach the android.support.v7.widget.RecyclerView instance and release internal field references.

void setCheckCanDropEnabled(boolean enabled)
Sets whether to use onCheckCanDrop(int, int).
void setDragEdgeScrollSpeed(float speed)
Sets drag edge scroll speed.
void setDragStartItemAlphaAnimationInterpolator(Interpolator interpolator)
Sets the interpolator which is used for "drag start alpha" item animation.
void setDragStartItemAnimationDuration(int duration)
Sets duration of "drag start" item animation.
void setDragStartItemRotationAnimationInterpolator(Interpolator interpolator)
Sets the interpolator which is used for "drag start rotation" item animation.
void setDragStartItemScaleAnimationInterpolator(Interpolator interpolator)
Sets the interpolator which is used for "drag start scaling" item animation.
void setDraggingItemAlpha(float alpha)
Sets dragging item alpha.
void setDraggingItemRotation(float rotation)
Sets dragging item rotation.
void setDraggingItemScale(float scale)
Sets dragging item scaling factor.
void setDraggingItemShadowDrawable(NinePatchDrawable drawable)
Sets 9-patch image which is used for the actively dragging item
void setInitiateOnLongPress(boolean initiateOnLongPress)
Sets whether dragging starts on a long press.
void setInitiateOnMove(boolean initiateOnMove)
Sets whether dragging starts on move motions.
void setInitiateOnTouch(boolean initiateOnTouch)
Sets whether dragging starts on touch the handle immediately.
void setItemMoveMode(int mode)
Sets item move
void setItemSettleBackIntoPlaceAnimationDuration(int duration)
Sets the duration of "settle back into place" animation.
void setItemSettleBackIntoPlaceAnimationInterpolator(Interpolator interpolator)
Sets the interpolator which is used for "settle back into place" animation.
void setLongPressTimeout(int longPressTimeout)
Sets the time required to consider press as long press.
void setOnItemDragEventListener(RecyclerViewDragDropManager.OnItemDragEventListener listener)
Sets OnItemDragEventListener listener
Interpolator setSwapTargetTranslationInterpolator()
Gets the interpolator which ise used for determining the position of the swapping item.
void setSwapTargetTranslationInterpolator(Interpolator interpolator)
Sets the interpolator which is used for determining the position of the swapping item.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ITEM_MOVE_MODE_DEFAULT

Default item move mode

Constant Value: 0 (0x00000000)

public static final int ITEM_MOVE_MODE_SWAP

Swap two items between dragging item and the item under a finger (or mouse pointer)

Constant Value: 1 (0x00000001)

Fields

public static final Interpolator DEFAULT_ITEM_SETTLE_BACK_INTO_PLACE_ANIMATION_INTERPOLATOR

Default interpolator used for "item settle back into place" animation

public static final Interpolator DEFAULT_SWAP_TARGET_TRANSITION_INTERPOLATOR

Default interpolator used for "swap target transition"

Public Constructors

public RecyclerViewDragDropManager ()

Constructor.

Public Methods

public void attachRecyclerView (RecyclerView rv)

Attaches android.support.v7.widget.RecyclerView instance.

Before calling this method, the target android.support.v7.widget.RecyclerView must set the wrapped adapter instance which is returned by the createWrappedAdapter(android.support.v7.widget.RecyclerView.Adapter) method.

Parameters
rv The android.support.v7.widget.RecyclerView instance

public void cancelDrag ()

Cancel dragging.

public Adapter createWrappedAdapter (Adapter adapter)

Create wrapped adapter.

Parameters
adapter The target adapter.
Returns

public float getDragEdgeScrollSpeed ()

Gets drag edge scroll speed.

Returns
  • The coefficient value of drag edges scrolling speed.

public Interpolator getDragStartItemAlphaAnimationInterpolator ()

Gets the interpolator which ise used for "drag start alpha" animation.

Returns
  • Interpolator which is used for "drag start alpha" animation

public int getDragStartItemAnimationDuration ()

Gets the duration of "drag start" animation.

Returns
  • The duration of "drag start" animation in milliseconds

public Interpolator getDragStartItemRotationAnimationInterpolator ()

Gets the interpolator which ise used for "drag start rotation" animation.

Returns
  • Interpolator which is used for "drag start rotation" animation

public Interpolator getDragStartItemScaleAnimationInterpolator ()

Gets the interpolator which ise used for "drag start scaling" animation.

Returns
  • Interpolator which is used for "drag start scaling" animation

public float getDraggingItemAlpha ()

Gets dragging item alpha.

Returns
  • Alpha

public float getDraggingItemRotation ()

Gets dragging item rotation.

Returns
  • Rotation in degrees

public float getDraggingItemScale ()

Gets dragging item scaling factor.

Returns
  • Scaling factor

public int getItemMoveMode ()

Gets item move mode

Returns
  • item move mode

public int getItemSettleBackIntoPlaceAnimationDuration ()

Gets the duration of "settle back into place" animation.

Returns
  • The duration of "settle back into place" animation in milliseconds

public Interpolator getItemSettleBackIntoPlaceAnimationInterpolator ()

Gets the interpolator which ise used for "settle back into place" animation.

Returns
  • Interpolator which is used for "settle back into place" animation

public RecyclerViewDragDropManager.OnItemDragEventListener getOnItemDragEventListener ()

Gets OnItemDragEventListener listener

Returns
  • The listener object

public boolean isCheckCanDropEnabled ()

Gets whether to use onCheckCanDrop(int, int).

Returns

public boolean isDragging ()

Indicates whether currently performing item dragging.

Returns
  • True if currently performing item dragging

public boolean isInitiateOnLongPressEnabled ()

Returns whether dragging starts on a long press or not.

Returns
  • True if dragging starts on a long press, false otherwise.

public boolean isInitiateOnMoveEnabled ()

Returns whether dragging starts on move motions.

Returns
  • True if dragging starts on move motions, false otherwise.

public boolean isInitiateOnTouchEnabled ()

Returns whether dragging starts on touch the handle immediately.

Returns
  • True if dragging starts on touch the handle immediately, false otherwise.

public boolean isReleased ()

Indicates this manager instance has released or not.

Returns
  • True if this manager instance has released

public void release ()

Detach the android.support.v7.widget.RecyclerView instance and release internal field references.

This method should be called in order to avoid memory leaks.

public void setCheckCanDropEnabled (boolean enabled)

Sets whether to use onCheckCanDrop(int, int).

Parameters
enabled True if use onCheckCanDrop(int, int).

public void setDragEdgeScrollSpeed (float speed)

Sets drag edge scroll speed.

Parameters
speed The coefficient value of drag edge scrolling speed. (valid range: 0.0f .. 2.0)

public void setDragStartItemAlphaAnimationInterpolator (Interpolator interpolator)

Sets the interpolator which is used for "drag start alpha" item animation.

Parameters
interpolator Interpolator to set or null to clear

public void setDragStartItemAnimationDuration (int duration)

Sets duration of "drag start" item animation.

Parameters
duration Specify the animation duration in milliseconds

public void setDragStartItemRotationAnimationInterpolator (Interpolator interpolator)

Sets the interpolator which is used for "drag start rotation" item animation.

Parameters
interpolator Interpolator to set or null to clear

public void setDragStartItemScaleAnimationInterpolator (Interpolator interpolator)

Sets the interpolator which is used for "drag start scaling" item animation.

Parameters
interpolator Interpolator to set or null to clear

public void setDraggingItemAlpha (float alpha)

Sets dragging item alpha.

Parameters
alpha Alpha (e.g. 1.0: fully opaque, 0.0: fully transparent)

public void setDraggingItemRotation (float rotation)

Sets dragging item rotation.

Parameters
rotation Rotation in degrees

public void setDraggingItemScale (float scale)

Sets dragging item scaling factor.

Parameters
scale Scaling factor (e.g. 1.0: no scaling, 2.0: 2x scaling)

public void setDraggingItemShadowDrawable (NinePatchDrawable drawable)

Sets 9-patch image which is used for the actively dragging item

Parameters
drawable The 9-patch drawable

public void setInitiateOnLongPress (boolean initiateOnLongPress)

Sets whether dragging starts on a long press. (default: false)

Parameters
initiateOnLongPress True to initiate dragging on long press.

public void setInitiateOnMove (boolean initiateOnMove)

Sets whether dragging starts on move motions. (default: true)

Parameters
initiateOnMove True to initiate dragging on move motions.

public void setInitiateOnTouch (boolean initiateOnTouch)

Sets whether dragging starts on touch the handle immediately. (default: false)

Parameters
initiateOnTouch True to initiate dragging on touch the handle immediately.

public void setItemMoveMode (int mode)

Sets item move

Parameters
mode item move mode

public void setItemSettleBackIntoPlaceAnimationDuration (int duration)

Sets the duration of "settle back into place" animation.

Parameters
duration Specify the animation duration in milliseconds

public void setItemSettleBackIntoPlaceAnimationInterpolator (Interpolator interpolator)

Sets the interpolator which is used for "settle back into place" animation.

Parameters
interpolator Interpolator to set or null to clear

public void setLongPressTimeout (int longPressTimeout)

Sets the time required to consider press as long press. (default: 500ms)

Parameters
longPressTimeout Integer in milli seconds.

public void setOnItemDragEventListener (RecyclerViewDragDropManager.OnItemDragEventListener listener)

Sets OnItemDragEventListener listener

Parameters
listener The listener object

public Interpolator setSwapTargetTranslationInterpolator ()

Gets the interpolator which ise used for determining the position of the swapping item.

Returns
  • Interpolator which is used for determining the position of the swapping item

public void setSwapTargetTranslationInterpolator (Interpolator interpolator)

Sets the interpolator which is used for determining the position of the swapping item.

Parameters
interpolator Interpolator to set or null to clear