ViewDragHelper.Callback

public static abstract class ViewDragHelper.Callback
extends Object

java.lang.Object
   ↳ androidx.customview.widget.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.

Summary

Public constructors

Callback()

Public methods

int clampViewPositionHorizontal(View child, int left, int dx)

Restrict the motion of the dragged child view along the horizontal axis.

int clampViewPositionVertical(View child, int top, int dy)

Restrict the motion of the dragged child view along the vertical axis.

int getOrderedChildIndex(int index)

Called to determine the Z-order of child views.

int getViewHorizontalDragRange(View child)

Return the magnitude of a draggable child view's horizontal range of motion in pixels.

int getViewVerticalDragRange(View child)

Return the magnitude of a draggable child view's vertical range of motion in pixels.

void onEdgeDragStarted(int edgeFlags, int pointerId)

Called when the user has started a deliberate drag away from one of the subscribed edges in the parent view while no child view is currently captured.

boolean onEdgeLock(int edgeFlags)

Called when the given edge may become locked.

void onEdgeTouched(int edgeFlags, int pointerId)

Called when one of the subscribed edges in the parent view has been touched by the user while no child view is currently captured.

void onViewCaptured(View capturedChild, int activePointerId)

Called when a child view is captured for dragging or settling.

void onViewDragStateChanged(int state)

Called when the drag state changes.

void onViewPositionChanged(View changedView, int left, int top, int dx, int dy)

Called when the captured view's position changes as the result of a drag or settle.

void onViewReleased(View releasedChild, float xvel, float yvel)

Called when the child view is no longer being actively dragged.

abstract boolean tryCaptureView(View child, int pointerId)

Called when the user's input indicates that they want to capture the given child view with the pointer indicated by pointerId.

Inherited methods

Public constructors

Callback

public Callback ()

Public methods

clampViewPositionHorizontal

public int clampViewPositionHorizontal (View child, 
                int left, 
                int dx)

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

public int clampViewPositionVertical (View child, 
                int top, 
                int dy)

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.

Parameters
child View: Child view being dragged

top int: Attempted motion along the Y axis

dy int: Proposed change in position for top

Returns
int The new clamped position for top

getOrderedChildIndex

public int getOrderedChildIndex (int index)

Called to determine the Z-order of child views.

Parameters
index int: the ordered position to query for

Returns
int index of the view that should be ordered at position index

getViewHorizontalDragRange

public int getViewHorizontalDragRange (View child)

Return the magnitude of a draggable child view's horizontal range of motion in pixels. This method should return 0 for views that cannot move horizontally.

Parameters
child View: Child view to check

Returns
int range of horizontal motion in pixels

getViewVerticalDragRange

public int getViewVerticalDragRange (View child)

Return the magnitude of a draggable child view's vertical range of motion in pixels. This method should return 0 for views that cannot move vertically.

Parameters
child View: Child view to check

Returns
int range of vertical motion in pixels

onEdgeDragStarted

public void onEdgeDragStarted (int edgeFlags, 
                int pointerId)

Called when the user has started a deliberate drag away from one of the subscribed edges in the parent view while no child view is currently captured.

Parameters