MotionEventBuilder


class MotionEventBuilder


A helper builder for creating MotionEvent's.

Default values for unspecified attributes are 0 unless otherwise noted.

Summary

Public functions

MotionEvent!

Returns a MotionEvent with the provided data or reasonable defaults.

java-static MotionEventBuilder!

Start building a new MotionEvent.

MotionEventBuilder!
setAction(action: Int)

Sets the action.

MotionEventBuilder!
setActionIndex(pointerIndex: Int)

Sets the pointer index associated with the action.

MotionEventBuilder!
setButtonState(buttonState: Int)

Sets the button state.

MotionEventBuilder!
setDeviceId(deviceId: Int)

Sets the device id.

MotionEventBuilder!
setDownTime(downTime: Long)

Sets the down time.

MotionEventBuilder!
setEdgeFlags(edgeFlags: Int)

Sets the edge flags.

MotionEventBuilder!
setEventTime(eventTime: Long)

Sets the event time.

MotionEventBuilder!
setFlags(flags: Int)

Sets the flags.

MotionEventBuilder!
setMetaState(metastate: Int)

Sets the metaState.

MotionEventBuilder!
setPointer(
    pointerProperties: MotionEvent.PointerProperties!,
    pointerCoords: MotionEvent.PointerCoords!
)

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

MotionEventBuilder!

Simple mechanism to add a pointer to the MotionEvent.

MotionEventBuilder!
setSource(source: Int)

Sets the source.

MotionEventBuilder!
setXPrecision(xPrecision: Float)

Sets the x precision.

MotionEventBuilder!
setYPrecision(yPrecision: Float)

Sets the y precision.

Public functions

build

fun build(): MotionEvent!

Returns a MotionEvent with the provided data or reasonable defaults.

newBuilder

java-static fun newBuilder(): MotionEventBuilder!

Start building a new MotionEvent.

Returns
MotionEventBuilder!

a new MotionEventBuilder.

setAction

fun setAction(action: Int): MotionEventBuilder!

Sets the action. Default is MotionEvent.ACTION_DOWN.

See also
getAction

setActionIndex

fun setActionIndex(pointerIndex: Int): MotionEventBuilder!

Sets the pointer index associated with the action.

See also
getActionIndex

setButtonState

fun setButtonState(buttonState: Int): MotionEventBuilder!

Sets the button state.

See also
getButtonState

setDeviceId

fun setDeviceId(deviceId: Int): MotionEventBuilder!

Sets the device id.

See also
getDeviceId

setDownTime

fun setDownTime(downTime: Long): MotionEventBuilder!

Sets the down time.

See also
getDownTime

setEdgeFlags

fun setEdgeFlags(edgeFlags: Int): MotionEventBuilder!

Sets the edge flags.

See also
getEdgeFlags

setEventTime

fun setEventTime(eventTime: Long): MotionEventBuilder!

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

See also
getEventTime

setFlags

fun setFlags(flags: Int): MotionEventBuilder!

Sets the flags.

See also
getFlags

setMetaState

fun setMetaState(metastate: Int): MotionEventBuilder!

Sets the metaState.

See also
getMetaState

setPointer

fun setPointer(
    pointerProperties: MotionEvent.PointerProperties!,
    pointerCoords: MotionEvent.PointerCoords!
): MotionEventBuilder!

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

setPointer

fun setPointer(x: Float, y: Float): MotionEventBuilder!

Simple mechanism to add a pointer to the MotionEvent.

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

setSource

fun setSource(source: Int): MotionEventBuilder!

Sets the source.

See also
getSource

setXPrecision

fun setXPrecision(xPrecision: Float): MotionEventBuilder!

Sets the x precision.

See also
getXPrecision

setYPrecision

fun setYPrecision(yPrecision: Float): MotionEventBuilder!

Sets the y precision.

See also
getYPrecision