ViewDragHelper.Callback

A Callback is used as a communication channel with the ViewDragHelper back to the
parent view using it. on*methods are invoked on siginficant events and several
accessor methods are expected to provide the ViewDragHelper with more information
about the state of the parent view upon request. The callback also makes decisions
governing the range and draggability of child views.

Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.

Public constructors

ViewDragHelper.Callback

Public methods

clampViewPositionHorizontal

Restrict the motion of the dragged child view along the horizontal axis.
The default implementation does not allow horizontal motion; the extending
class must override this method and provide the desired clamping.

Parameters

child

View: Child view being dragged

left

int: Attempted motion along the X axis

dx

int: Proposed change in position for left

Returns

int

The new clamped position for left

clampViewPositionVertical

Restrict the motion of the dragged child view along the vertical axis.
The default implementation does not allow vertical motion; the extending
class must override this method and provide the desired clamping.

onEdgeLock

Called when the given edge may become locked. This can happen if an edge drag
was preliminarily rejected before beginning, but after onEdgeTouched(int, int)
was called. This method should return true to lock this edge or false to leave it
unlocked. The default behavior is to leave edges unlocked.

onViewCaptured

Called when a child view is captured for dragging or settling. The ID of the pointer
currently dragging the captured view is supplied. If activePointerId is
identified as INVALID_POINTER the capture is programmatic instead of
pointer-initiated.

onViewReleased

Called when the child view is no longer being actively dragged.
The fling velocity is also supplied, if relevant. The velocity values may
be clamped to system minimums or maximums.

Calling code may decide to fling or otherwise release the view to let it
settle into place. It should do so using settleCapturedViewAt(int, int)
or flingCapturedView(int, int, int, int). If the Callback invokes
one of these methods, the ViewDragHelper will enter STATE_SETTLING
and the view capture will not fully end until it comes to a complete stop.
If neither of these methods is invoked before onViewReleased returns,
the view will stop in place and the ViewDragHelper will return to
STATE_IDLE.

Parameters

releasedChild

View: The captured child view now being released

xvel

float: X velocity of the pointer as it left the screen in pixels per second.

yvel

float: Y velocity of the pointer as it left the screen in pixels per second.

tryCaptureView

Called when the user's input indicates that they want to capture the given child view
with the pointer indicated by pointerId. The callback should return true if the user
is permitted to drag the given view with the indicated pointer.

ViewDragHelper may call this method multiple times for the same view even if
the view is already captured; this indicates that a new pointer is trying to take
control of the view.