Stay organized with collections Save and categorize content based on your preferences.

MotionEventBuilder

public class MotionEventBuilder


A helper builder for creating MotionEvent's.

Default values for unspecified attributes are 0 unless otherwise noted.

Summary

Public constructors

Public methods

MotionEvent

Returns a MotionEvent with the provided data or reasonable defaults.

static MotionEventBuilder

Start building a new MotionEvent.

MotionEventBuilder
setAction(int action)

Sets the action.

MotionEventBuilder
setActionIndex(int pointerIndex)

Sets the pointer index associated with the action.

MotionEventBuilder
setButtonState(int buttonState)

Sets the button state.

MotionEventBuilder
setDeviceId(int deviceId)

Sets the device id.

MotionEventBuilder
setDownTime(long downTime)

Sets the down time.

MotionEventBuilder
setEdgeFlags(int edgeFlags)

Sets the edge flags.

MotionEventBuilder
setEventTime(long eventTime)

Sets the event time.

MotionEventBuilder
setFlags(int flags)

Sets the flags.

MotionEventBuilder
setMetaState(int metastate)

Sets the metaState.

MotionEventBuilder
setPointer(
    PointerProperties pointerProperties,
    PointerCoords pointerCoords
)

An expanded variant of setPointer that supports specifying all pointer properties and coords data.

MotionEventBuilder
setPointer(float x, float y)

Simple mechanism to add a pointer to the MotionEvent.

MotionEventBuilder
setSource(int source)

Sets the source.

MotionEventBuilder
setXPrecision(float xPrecision)

Sets the x precision.

MotionEventBuilder
setYPrecision(float yPrecision)

Sets the y precision.

Public constructors

MotionEventBuilder

public MotionEventBuilder()

Public methods

build

public MotionEvent build()

Returns a MotionEvent with the provided data or reasonable defaults.

newBuilder

public static MotionEventBuilder newBuilder()

Start building a new MotionEvent.

Returns
MotionEventBuilder

a new MotionEventBuilder.

setAction

public MotionEventBuilder setAction(int action)

Sets the action. Default is MotionEvent.ACTION_DOWN.

See also
MotionEvent

setActionIndex

public MotionEventBuilder setActionIndex(int pointerIndex)

Sets the pointer index associated with the action.

See also
MotionEvent

setButtonState

public MotionEventBuilder setButtonState(int buttonState)

Sets the button state.

See also
MotionEvent

setDeviceId

public MotionEventBuilder setDeviceId(int deviceId)

Sets the device id.

See also
MotionEvent

setDownTime

public MotionEventBuilder setDownTime(long downTime)

Sets the down time.

See also
MotionEvent

setEdgeFlags

public MotionEventBuilder setEdgeFlags(int edgeFlags)

Sets the edge flags.

See also
MotionEvent

setEventTime

public MotionEventBuilder setEventTime(long eventTime)

Sets the event time. Default is SystemClock.uptimeMillis().

See also
MotionEvent

setFlags

public MotionEventBuilder setFlags(int flags)

Sets the flags.

See also
MotionEvent

setMetaState

public MotionEventBuilder setMetaState(int metastate)

Sets the metaState.

See also
MotionEvent

setPointer

public MotionEventBuilder setPointer(
    PointerProperties pointerProperties,
    PointerCoords pointerCoords
)

An expanded variant of setPointer that supports specifying all pointer properties and coords data.

setPointer

public MotionEventBuilder setPointer(float x, float y)

Simple mechanism to add a pointer to the MotionEvent.

Can be called multiple times to add multiple pointers to the event.

setSource

public MotionEventBuilder setSource(int source)

Sets the source.

See also
MotionEvent

setXPrecision

public MotionEventBuilder setXPrecision(float xPrecision)

Sets the x precision.

See also
MotionEvent

setYPrecision

public MotionEventBuilder setYPrecision(float yPrecision)

Sets the y precision.

See also
MotionEvent