MotionEventBuilder


public class MotionEventBuilder


A helper builder for creating MotionEvent's.

Default values for unspecified attributes are 0 unless otherwise noted.

Summary

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(
    MotionEvent.PointerProperties pointerProperties,
    MotionEvent.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 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
getAction

setActionIndex

public MotionEventBuilder setActionIndex(int pointerIndex)

Sets the pointer index associated with the action.

See also
getActionIndex

setButtonState

public MotionEventBuilder setButtonState(int buttonState)

Sets the button state.

See also
getButtonState

setDeviceId

public MotionEventBuilder setDeviceId(int deviceId)

Sets the device id.

See also
getDeviceId

setDownTime

public MotionEventBuilder setDownTime(long downTime)

Sets the down time.

See also
getDownTime

setEdgeFlags

public MotionEventBuilder setEdgeFlags(int edgeFlags)

Sets the edge flags.

See also
getEdgeFlags

setEventTime

public MotionEventBuilder setEventTime(long eventTime)

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

See also
getEventTime

setFlags

public MotionEventBuilder setFlags(int flags)

Sets the flags.

See also
getFlags

setMetaState

public MotionEventBuilder setMetaState(int metastate)

Sets the metaState.

See also
getMetaState

setPointer

public MotionEventBuilder setPointer(
    MotionEvent.PointerProperties pointerProperties,
    MotionEvent.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
getSource

setXPrecision

public MotionEventBuilder setXPrecision(float xPrecision)

Sets the x precision.

See also
getXPrecision

setYPrecision

public MotionEventBuilder setYPrecision(float yPrecision)

Sets the y precision.

See also
getYPrecision