com.doffman.dragarea
Class DragArea

java.lang.Object
  extended by FrameLayout
      extended by com.doffman.dragarea.DragArea

public class DragArea
extends FrameLayout

The DragArea is a standard FrameLayout that also provides Drag and Drop functionality. This class deals with drawing the drag shadow on top of its child views and handling data transfer and events for the drag operation. The drag shadow is a visualisation of the drag operation, an image placed beneath the users finger while dragging. Children of the DragArea may start a drag operation by calling the startDrag method. Once a drag operation has begun OnDragListener objects that have registered themselves with the addDragListener(View, com.doffman.dragarea.OnDragListener) method will be called with drag events that are relevent to them.


Constructor Summary
DragArea(Context context)
           
DragArea(Context context, AttributeSet attrs)
           
DragArea(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
 void addDragListener(View view, OnDragListener listener)
          Adds a drag listener to the drag area.
 void dispatchDraw(Canvas canvas)
           
 boolean onInterceptTouchEvent(MotionEvent event)
           
 boolean onTouchEvent(MotionEvent event)
           
 void removeDragListener(OnDragListener listener)
          Removes a drag listener.
 void startDrag(Bundle dragBundle, DragShadowBuilder shadowBuilder)
          Called to start a drag operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragArea

public DragArea(Context context)

DragArea

public DragArea(Context context,
                AttributeSet attrs)

DragArea

public DragArea(Context context,
                AttributeSet attrs,
                int defStyle)
Method Detail

startDrag

public void startDrag(Bundle dragBundle,
                      DragShadowBuilder shadowBuilder)
Called to start a drag operation.

Parameters:
dragBundle - Used to pass information between the object starting the drag and the object on which the drop operation occurs.
shadowBuilder - Used to create a visualization of the drag operation called a drag shadow.

addDragListener

public void addDragListener(View view,
                            OnDragListener listener)
Adds a drag listener to the drag area. The drag listener object will recieve relevent drag events once any drag operation has been started. The bounds of the associated view are needed to compare to the current touch point and decide which listener should recieve the drop event.

Parameters:
listener - A drag listener to be added to this drag area.
view - The view associated with this drag listener.

removeDragListener

public void removeDragListener(OnDragListener listener)
Removes a drag listener.

Parameters:
listener - The drag listener object to be removed.

onInterceptTouchEvent

public boolean onInterceptTouchEvent(MotionEvent event)

onTouchEvent

public boolean onTouchEvent(MotionEvent event)

dispatchDraw

public void dispatchDraw(Canvas canvas)