DifferentialMotionFlingController


public class DifferentialMotionFlingController


Controller differential motion flings.

Differential motion here refers to motions that report change in position instead of absolution position. For instance, differential data points of 2, -1, 5 represent: there was a movement by "2" units, then by "-1" units, then by "5" units. Examples of motions reported differentially include motions from AXIS_SCROLL.

The client should call onMotionEvent when a differential motion event happens on the target View (that is, the View on which we want to fling), and this class processes the event to orchestrate fling.

Note that this class currently works to control fling only in one direction at a time. As such, it works independently of horizontal/vertical orientations. It requests its client to start/stop fling, and it's up to the client to choose the fling direction based on its specific internal configurations and/or preferences.

Summary

Public constructors

Constructs an instance for a given DifferentialMotionFlingTarget.

Public methods

void
onMotionEvent(@NonNull MotionEvent event, int axis)

Called to report when a differential motion happens on the View that's the target for fling.

Public constructors

DifferentialMotionFlingController

Added in 1.13.0
public DifferentialMotionFlingController(
    @NonNull Context context,
    @NonNull DifferentialMotionFlingTarget target
)

Constructs an instance for a given DifferentialMotionFlingTarget.

Public methods

onMotionEvent

Added in 1.13.0
public void onMotionEvent(@NonNull MotionEvent event, int axis)

Called to report when a differential motion happens on the View that's the target for fling.

Parameters
@NonNull MotionEvent event

the MotionEvent being reported.

int axis

the axis being processed by the target View.