The Android Developer Challenge is back! Submit your idea before December 2.

DragObserver

interface DragObserver
androidx.ui.core.gesture.DragObserver

Summary

Public methods

open PxPosition
onDrag(dragDistance: PxPosition)

Override to be notified when a distance has been dragged.

open Unit
onStart(downPosition: PxPosition)

Override to be notified when a drag has started.

open Unit
onStop(velocity: PxPosition)

Override to be notified when a drag has stopped.

Public methods

onDrag

open fun onDrag(dragDistance: PxPosition
): PxPosition

Override to be notified when a distance has been dragged.

When overridden, return the amount of the dragDistance that has been consumed.

Called immediately after onStart and for every subsequent pointer movement, as long as the movement was enough to constitute a drag (the average movement on the x or y axis is not equal to 0).

Note: This may be called multiple times in a single pass and the values should be accumulated for each call.

Parameters
dragDistance: PxPosition = null: PxPosition The distance that has been dragged. Reflects the average drag distance of all pointers.

onStart

open fun onStart(downPosition: PxPosition
): Unit

Override to be notified when a drag has started.

This will be called as soon as the DragGestureDetector is allowed to start (canStartDragging is null or returns true) and the average distance the pointers have moved are not 0 on both the x and y axes.

Parameters
downPosition: PxPosition = null: PxPosition The pointer input position of the down event.

See Also

onStop

open fun onStop(velocity: PxPosition
): Unit

Override to be notified when a drag has stopped.

This is called once all pointers have stopped interacting with this DragGestureDetector.

Only called if the last call between onStart and onStop was onStart.