Callback
abstract class Callback
kotlin.Any | |
↳ | 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 | |
---|---|
<init>() A Callback is used as a communication channel with the ViewDragHelper back to the parent view using it. |
Public methods | |
---|---|
open Int |
clampViewPositionHorizontal(@NonNull child: View, left: Int, dx: Int) Restrict the motion of the dragged child view along the horizontal axis. |
open Int |
clampViewPositionVertical(@NonNull child: View, top: Int, dy: Int) Restrict the motion of the dragged child view along the vertical axis. |
open Int |
getOrderedChildIndex(index: Int) Called to determine the Z-order of child views. |
open Int |
getViewHorizontalDragRange(@NonNull child: View) Return the magnitude of a draggable child view's horizontal range of motion in pixels. |
open Int |
getViewVerticalDragRange(@NonNull child: View) Return the magnitude of a draggable child view's vertical range of motion in pixels. |
open Unit |
onEdgeDragStarted(edgeFlags: Int, pointerId: Int) 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. |
open Boolean |
onEdgeLock(edgeFlags: Int) Called when the given edge may become locked. |
open Unit |
onEdgeTouched(edgeFlags: Int, pointerId: Int) Called when one of the subscribed edges in the parent view has been touched by the user while no child view is currently captured. |
open Unit |
onViewCaptured(@NonNull capturedChild: View, activePointerId: Int) Called when a child view is captured for dragging or settling. |
open Unit |
onViewDragStateChanged(state: Int) Called when the drag state changes. |
open Unit |
Called when the captured view's position changes as the result of a drag or settle. |
open Unit |
onViewReleased(@NonNull releasedChild: View, xvel: Float, yvel: Float) Called when the child view is no longer being actively dragged. |
abstract Boolean |
tryCaptureView(@NonNull child: View, pointerId: Int) Called when the user's input indicates that they want to capture the given child view with the pointer indicated by pointerId. |
Public constructors
<init>
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.
Public methods
clampViewPositionHorizontal
open fun clampViewPositionHorizontal(
@NonNull child: View,
left: Int,
dx: Int
): Int
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 |
Return | |
---|---|
Int |
The new clamped position for left |
clampViewPositionVertical
open fun clampViewPositionVertical(
@NonNull child: View,
top: Int,
dy: Int
): Int
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 |
Return | |
---|---|
Int |
The new clamped position for top |
getOrderedChildIndex
open fun getOrderedChildIndex(index: Int): Int
Called to determine the Z-order of child views.
Parameters | |
---|---|
index |
Int: the ordered position to query for |
Return | |
---|---|
Int |
index of the view that should be ordered at position index |
getViewHorizontalDragRange
open fun getViewHorizontalDragRange(@NonNull child: View): Int
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 |
Return | |
---|---|
Int |
range of horizontal motion in pixels |
getViewVerticalDragRange
open fun getViewVerticalDragRange(@NonNull child: View): Int
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 |
Return | |
---|---|
Int |
range of vertical motion in pixels |
onEdgeDragStarted
open fun onEdgeDragStarted(
edgeFlags: Int,
pointerId: Int
): Unit
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 | |
---|---|
edgeFlags |
Int: A combination of edge flags describing the edge(s) dragged |
pointerId |
Int: ID of the pointer touching the described edge(s) |
See Also