NavigationEventInput


public abstract class NavigationEventInput

Known direct subclasses
DirectNavigationEventInput

An input that can send events to a NavigationEventDispatcher.

OnBackInvokedInput

Provides input to a NavigationEventDispatcher by registering an OnBackInvokedCallback to the passed in onBackInvokedDispatcher.


An abstract class for components that generate and dispatch navigation events.

This class acts as the "input" side of the navigation system, translating platform-specific events (like system back gestures or button clicks) into standardized events that can be sent to a NavigationEventDispatcher.

Subclasses are responsible for implementing the logic that sources these events and calling the dispatchOn... methods (e.g., dispatchOnBackStarted) to propagate them through the system.

An input must be registered with a NavigationEventDispatcher using NavigationEventDispatcher.addInput to function.

Summary

Public constructors

Protected methods

final void

Notifies the dispatcher that the ongoing TRANSITIONING_BACK navigation gesture has been cancelled.

final void

Notifies the dispatcher that the ongoing TRANSITIONING_BACK navigation gesture has completed.

final void

Notifies the dispatcher that an ongoing TRANSITIONING_BACK navigation gesture has progressed.

final void

Notifies the dispatcher that a TRANSITIONING_BACK navigation gesture has started.

final void

Notifies the dispatcher that the ongoing TRANSITIONING_FORWARD navigation gesture has been cancelled.

final void

Notifies the dispatcher that the ongoing TRANSITIONING_FORWARD navigation gesture has completed.

final void

Notifies the dispatcher that an ongoing TRANSITIONING_FORWARD navigation gesture has progressed.

final void

Notifies the dispatcher that a TRANSITIONING_FORWARD navigation gesture has started.

void

Called after this NavigationEventInput is added to dispatcher.

void

Called when the enabled state of handlers in the connected NavigationEventDispatcher changes.

void

Called when the NavigationEventHistory state in the connected NavigationEventDispatcher changes.

void

Called after this NavigationEventInput is removed from a NavigationEventDispatcher.

Public constructors

Added in 1.0.0-alpha09
public NavigationEventInput()

Protected methods

dispatchOnBackCancelled

Added in 1.0.0-alpha09
@MainThread
protected final void dispatchOnBackCancelled()

Notifies the dispatcher that the ongoing TRANSITIONING_BACK navigation gesture has been cancelled.

This is a terminal event. The NavigationEventDispatcher.transitionState will become Idle and ready for a new gesture.

Throws
kotlin.IllegalStateException

if this input is not added to a dispatcher.

kotlin.IllegalStateException

if this dispatcher is disposed.

dispatchOnBackCompleted

Added in 1.0.0-alpha09
@MainThread
protected final void dispatchOnBackCompleted()

Notifies the dispatcher that the ongoing TRANSITIONING_BACK navigation gesture has completed.

This is a terminal event, signaling that the navigation should be finalized (e.g., popping the back stack). The NavigationEventDispatcher.transitionState will become Idle and ready for a new gesture.

Throws
kotlin.IllegalStateException

if this input is not added to a dispatcher.

kotlin.IllegalStateException

if this dispatcher is disposed.

dispatchOnBackProgressed

Added in 1.0.0-alpha09
@MainThread
protected final void dispatchOnBackProgressed(@NonNull NavigationEvent event)

Notifies the dispatcher that an ongoing TRANSITIONING_BACK navigation gesture has progressed.

The NavigationEventDispatcher.transitionState will become InProgress.

Parameters
@NonNull NavigationEvent event

The NavigationEvent describing the progress of the gesture.

Throws
kotlin.IllegalStateException

if this input is not added to a dispatcher.

kotlin.IllegalStateException

if this dispatcher is disposed.

dispatchOnBackStarted

Added in 1.0.0-alpha09
@MainThread
protected final void dispatchOnBackStarted(@NonNull NavigationEvent event)

Notifies the dispatcher that a TRANSITIONING_BACK navigation gesture has started.

The NavigationEventDispatcher.transitionState will become InProgress.

Parameters
@NonNull NavigationEvent event

The NavigationEvent describing the start of the gesture (e.g., touch position).

Throws
kotlin.IllegalStateException

if this input is not added to a dispatcher.

kotlin.IllegalStateException

if this dispatcher is disposed.

dispatchOnForwardCancelled

Added in 1.0.0-alpha09
@MainThread
protected final void dispatchOnForwardCancelled()

Notifies the dispatcher that the ongoing TRANSITIONING_FORWARD navigation gesture has been cancelled.

This is a terminal event. The NavigationEventDispatcher.transitionState will become Idle and ready for a new gesture.

Throws
kotlin.IllegalStateException

if this input is not added to a dispatcher.

kotlin.IllegalStateException

if this dispatcher is disposed.

dispatchOnForwardCompleted

Added in 1.0.0-alpha09
@MainThread
protected final void dispatchOnForwardCompleted()

Notifies the dispatcher that the ongoing TRANSITIONING_FORWARD navigation gesture has completed.

This is a terminal event, signaling that the navigation should be finalized (e.g., popping the back stack). The NavigationEventDispatcher.transitionState will become Idle and ready for a new gesture.

Throws
kotlin.IllegalStateException

if this input is not added to a dispatcher.

kotlin.IllegalStateException

if this dispatcher is disposed.

dispatchOnForwardProgressed

Added in 1.0.0-alpha09
@MainThread
protected final void dispatchOnForwardProgressed(@NonNull NavigationEvent event)

Notifies the dispatcher that an ongoing TRANSITIONING_FORWARD navigation gesture has progressed.

The NavigationEventDispatcher.transitionState will become InProgress.

Parameters
@NonNull NavigationEvent event

The NavigationEvent describing the progress of the gesture.

Throws
kotlin.IllegalStateException

if this input is not added to a dispatcher.

kotlin.IllegalStateException

if this dispatcher is disposed.

dispatchOnForwardStarted

Added in 1.0.0-alpha09
@MainThread
protected final void dispatchOnForwardStarted(@NonNull NavigationEvent event)

Notifies the dispatcher that a TRANSITIONING_FORWARD navigation gesture has started.

The NavigationEventDispatcher.transitionState will become InProgress.

Parameters
@NonNull NavigationEvent event

The NavigationEvent describing the start of the gesture (e.g., touch position).

Throws
kotlin.IllegalStateException

if this input is not added to a dispatcher.

kotlin.IllegalStateException

if this dispatcher is disposed.

onAdded

Added in 1.0.0-alpha09
@MainThread
@EmptySuper
protected void onAdded(@NonNull NavigationEventDispatcher dispatcher)

Called after this NavigationEventInput is added to dispatcher. This can happen when calling NavigationEventDispatcher.addInput. A NavigationEventInput can only be added to one NavigationEventDispatcher at a time.

Parameters
@NonNull NavigationEventDispatcher dispatcher

The NavigationEventDispatcher that this input is now added to.

onHasEnabledHandlersChanged

Added in 1.0.0-alpha09
@MainThread
@EmptySuper
protected void onHasEnabledHandlersChanged(boolean hasEnabledHandlers)

Called when the enabled state of handlers in the connected NavigationEventDispatcher changes.

This allows the input to enable or disable its own event sourcing. For example, a system back gesture input might only register for gestures when hasEnabledHandlers is true.

The exact set of handlers this reflects depends on the Priority this input was registered with.

Parameters
boolean hasEnabledHandlers

Whether the connected dispatcher has any enabled handlers matching this input's priority scope.

onHistoryChanged

Added in 1.0.0-alpha09
@MainThread
@EmptySuper
protected void onHistoryChanged(@NonNull NavigationEventHistory history)

Called when the NavigationEventHistory state in the connected NavigationEventDispatcher changes.

Parameters
@NonNull NavigationEventHistory history

The new, immutable snapshot of the navigation history.

onRemoved

Added in 1.0.0-alpha09
@MainThread
@EmptySuper
protected void onRemoved()

Called after this NavigationEventInput is removed from a NavigationEventDispatcher. This can happen when calling NavigationEventDispatcher.removeInput or NavigationEventDispatcher.dispose on the containing NavigationEventDispatcher.