public class DragAndDropHandler extends Object implements TouchEventHandler
Swappable ListAdapter.
This class only works properly on API levels 14 and higher.
Users of this class must call onTouchEvent(android.view.MotionEvent) and dispatchDraw(android.graphics.Canvas) on the right moments.| Constructor and Description |
|---|
DragAndDropHandler(DragAndDropListViewWrapper dragAndDropListViewWrapper)
Creates a new
DragAndDropHandler for the listview implementation
in given DragAndDropListViewWrapper |
DragAndDropHandler(DynamicListView dynamicListView)
Creates a new
DragAndDropHandler for given DynamicListView. |
| Modifier and Type | Method and Description |
|---|---|
void |
dispatchDraw(Canvas canvas) |
boolean |
isInteracting() |
boolean |
onTouchEvent(MotionEvent event)
Dispatches the
MotionEvents to their proper methods if applicable. |
void |
setAdapter(ListAdapter adapter) |
void |
setDraggableManager(DraggableManager draggableManager)
Sets the
DraggableManager to be used for determining whether an item should be dragged when the user issues a down MotionEvent. |
void |
setOnItemMovedListener(OnItemMovedListener onItemMovedListener)
Sets the
OnItemMovedListener that is notified when user has dropped a dragging item. |
void |
setScrollSpeed(float speed)
Sets the scroll speed when dragging an item.
|
void |
startDragging(int position)
Starts dragging the item at given position.
|
public DragAndDropHandler(DynamicListView dynamicListView)
DragAndDropHandler for given DynamicListView.dynamicListView - the DynamicListView to use.public DragAndDropHandler(DragAndDropListViewWrapper dragAndDropListViewWrapper)
DragAndDropHandler for the listview implementation
in given DragAndDropListViewWrapperdragAndDropListViewWrapper - the DragAndDropListViewWrapper which wraps the listview implementation to use.public void setAdapter(ListAdapter adapter)
IllegalStateException - if the adapter does not have stable ids.IllegalArgumentException - if the adapter does not implement Swappable.public void setScrollSpeed(float speed)
1.0f.speed - <1.0f to slow down scrolling, >1.0f to speed up scrolling.public void startDragging(int position)
DynamicListView.position - the position of the item in the adapter to start dragging. Be sure to subtract any header views.IllegalStateException - if the user is not touching this DynamicListView,
or if there is no adapter set.public void setDraggableManager(DraggableManager draggableManager)
DraggableManager to be used for determining whether an item should be dragged when the user issues a down MotionEvent.public void setOnItemMovedListener(OnItemMovedListener onItemMovedListener)
OnItemMovedListener that is notified when user has dropped a dragging item.public boolean isInteracting()
isInteracting in interface TouchEventHandlerpublic boolean onTouchEvent(MotionEvent event)
MotionEvents to their proper methods if applicable.onTouchEvent in interface TouchEventHandlerevent - the MotionEvent.true if the event was handled, false otherwise.public void dispatchDraw(Canvas canvas)