public final class NavigationEvent


Represents a system navigation event, such as a predictive back gesture or a back button press.

This class standardizes various platform signals (e.g., touch gestures, key events) into a single, consistent format. This allows handlers like NavigationEventDispatcher to process navigation actions uniformly without needing to know the specific source of the event.

Note that not all parameters apply to every type of navigation event. For example, touchX and touchY are only relevant for gesture-based navigation.

Summary

Constants

static final int

Indicates the navigation gesture originates from the left edge of the screen.

static final int

Indicates the navigation event was not caused by an edge swipe.

static final int

Indicates the navigation gesture originates from the right edge of the screen.

Public constructors

NavigationEvent(
    @FloatRange(from = 0.0) float touchX,
    @FloatRange(from = 0.0) float touchY,
    @FloatRange(from = 0.0, to = 1.0) float progress,
    int swipeEdge,
    long frameTimeMillis
)

Public methods

boolean
equals(Object other)
final long

The timestamp in milliseconds when this navigation event occurred.

final float

A normalized value from 0.0F to 1.0F indicating how far the navigation action has progressed.

final int

Indicates which screen edge a swipe-based navigation gesture originates from.

final float

The absolute X coordinate of the touch point for this event, in pixels, in the coordinate space of the screen.

final float

The absolute Y coordinate of the touch point for this event, in pixels, in the coordinate space of the screen.

int
@NonNull String

Constants

EDGE_LEFT

public static final int EDGE_LEFT = 0

Indicates the navigation gesture originates from the left edge of the screen.

EDGE_NONE

public static final int EDGE_NONE = 2

Indicates the navigation event was not caused by an edge swipe. This applies to actions like a 3-button navigation press or a hardware back button event.

EDGE_RIGHT

public static final int EDGE_RIGHT = 1

Indicates the navigation gesture originates from the right edge of the screen.

Public constructors

Added in 1.0.0-alpha06
public NavigationEvent(
    @FloatRange(from = 0.0) float touchX,
    @FloatRange(from = 0.0) float touchY,
    @FloatRange(from = 0.0, to = 1.0) float progress,
    int swipeEdge,
    long frameTimeMillis
)

Public methods

equals

public boolean equals(Object other)

getFrameTimeMillis

Added in 1.0.0-alpha06
public final long getFrameTimeMillis()

The timestamp in milliseconds when this navigation event occurred. This is useful for synchronizing animations or for debugging event sequences.

getProgress

Added in 1.0.0-alpha06
public final float getProgress()

A normalized value from 0.0F to 1.0F indicating how far the navigation action has progressed.

For continuous gestures like a swipe, this value will update incrementally. For discrete actions like a button press, a single event with progress of 0.0F may be sent when the action starts, followed by a completion signal.

getSwipeEdge

Added in 1.0.0-alpha06
public final int getSwipeEdge()

Indicates which screen edge a swipe-based navigation gesture originates from. For non-swipe events, this will be EDGE_NONE.

getTouchX

Added in 1.0.0-alpha06
public final float getTouchX()

The absolute X coordinate of the touch point for this event, in pixels, in the coordinate space of the screen. For events not triggered by a touch gesture (e.g., a key press), this will be 0.0F.

getTouchY

Added in 1.0.0-alpha06
public final float getTouchY()

The absolute Y coordinate of the touch point for this event, in pixels, in the coordinate space of the screen. For events not triggered by a touch gesture (e.g., a key press), this will be 0.0F.

hashCode

public int hashCode()

toString

public @NonNull String toString()