public class

MotionEventBuilder

extends Object
java.lang.Object
   ↳ androidx.test.core.view.MotionEventBuilder

Class Overview

A helper builder for creating MotionEvent's.

Default values for unspecified attributes are 0 unless otherwise noted.

Summary

Public Methods
MotionEvent build()
Returns a MotionEvent with the provided data or reasonable defaults.
static MotionEventBuilder newBuilder()
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(float, float) 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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public MotionEvent build ()

Returns a MotionEvent with the provided data or reasonable defaults.

Returns
MotionEvent

public static MotionEventBuilder newBuilder ()

Start building a new MotionEvent.

Returns
MotionEventBuilder a new MotionEventBuilder.

public MotionEventBuilder setAction (int action)

Sets the action. Default is ERROR(/MotionEvent.ACTION_DOWN).

Parameters
action int
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setActionIndex (int pointerIndex)

Sets the pointer index associated with the action.

Parameters
pointerIndex int
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setButtonState (int buttonState)

Sets the button state.

Parameters
buttonState int
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setDeviceId (int deviceId)

Sets the device id.

Parameters
deviceId int
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setDownTime (long downTime)

Sets the down time.

Parameters
downTime long
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setEdgeFlags (int edgeFlags)

Sets the edge flags.

Parameters
edgeFlags int
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setEventTime (long eventTime)

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

Parameters
eventTime long
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setFlags (int flags)

Sets the flags.

Parameters
flags int
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setMetaState (int metastate)

Sets the metaState.

Parameters
metastate int
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setPointer (MotionEvent.PointerProperties pointerProperties, MotionEvent.PointerCoords pointerCoords)

An expanded variant of setPointer(float, float) that supports specifying all pointer properties and coords data.

Parameters
pointerProperties MotionEvent.PointerProperties
pointerCoords MotionEvent.PointerCoords
Returns
MotionEventBuilder

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.

Parameters
x float
y float
Returns
MotionEventBuilder

public MotionEventBuilder setSource (int source)

Sets the source.

Parameters
source int
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setXPrecision (float xPrecision)

Sets the x precision.

Parameters
xPrecision float
Returns
MotionEventBuilder

See also:

public MotionEventBuilder setYPrecision (float yPrecision)

Sets the y precision.

Parameters
yPrecision float
Returns
MotionEventBuilder

See also: