AmbientManager.AmbientTransitionListener
public
static
interface
AmbientManager.AmbientTransitionListener
| com.google.wear.services.ambient.AmbientManager.AmbientTransitionListener |
The callbacks that an ambient component must implement and provide to the AmbientManager at the time of registration i.e. AmbientManager.createController(Context,AmbientOptions) via the created options in order to
handle specific ambient entry transitions (i.e. animations or any other visual effects) as
part of their support for ambient mode.
By creating an AmbientOptions instance with no transition listener, the component
can indicate that there will be no transition associated with the ambient state change event
(so the AmbientManager will skip the transition trigger altogether and immediately
trigger the state change event instead - i.e.
AmbientOptions myOptions = AmbientOptions.makeActivityOptions(
new ComponentName(...),
myActivity.getActivityToken(),
myActivity.getWindow(),
myActivityStateRegistry,
myLifecycleListener,
null); // transitionListener
Summary
Public methods | |
|---|---|
abstract
void
|
onCancelAmbientTransition(boolean timedOut)
The component will receive this callback on a non-UI thread to signal that the transition
started in |
abstract
void
|
onStartAmbientTransition(AmbientManager.TransitionDetails details, AmbientManager.AmbientTransitionFinishedNotifier finishNotifier)
The component will receive this callback on the main/UI thread when the system is preparing to enter or exit ambient mode. |
Public methods
onCancelAmbientTransition
public abstract void onCancelAmbientTransition (boolean timedOut)
The component will receive this callback on a non-UI thread to signal that the transition
started inonStartAmbientTransition(AmbientManager.TransitionDetails,AmbientTransitionFinishedNotifier) is being cancelled.
If it is being cancelled tue to exceeded the allowable duration for
animations/transitions leading to ambient entry (timedOut will be true).
For whatever reason, when the component receives this callback they should immediately wrap up any UI updates as the system will no longer guarantee that any new UI updates will be relfected on the display, especially when entering ambient.
| Parameters | |
|---|---|
timedOut |
boolean: true if the reason for the cancellation was a timeout on the
duration of the transition, otherwise false. |
onStartAmbientTransition
public abstract void onStartAmbientTransition (AmbientManager.TransitionDetails details, AmbientManager.AmbientTransitionFinishedNotifier finishNotifier)
The component will receive this callback on the main/UI thread when the system is preparing to enter or exit ambient mode.
Note that this transition callback will not always be triggered prior to ambient entry
or eixt as there are times that the system requires immediate entry to or exit from
ambient without any additional time or allowance for components to transition their UI.
However, when it is called, it will always be before AmbientComponentListener.onEnterAmbient(AmbientManager.ConfigurationDetails,boolean)
or AmbientComponentListener.onExitAmbient().
Components should be mindful that spending too much time here, exceeding the
established limit for transition duration, will result in a timeout with onCancelAmbientTransition(boolean) being called on a separate thread.
At this point, the system will be proceeding with ambient entry or exit regardless of
the state of the component and it should ensure that any remaining UI updates are
completed in AmbientComponentListener.onEnterAmbient(AmbientManager.ConfigurationDetails,boolean) or
AmbientComponentListener.onExitAmbient().
If a component finishes their animation/UI updates early (or wants to skip them for
some reason), calling the provided finishedCallback will signal the system that
ambient entry or exit can occur without any further delay.
| Parameters | |
|---|---|
details |
AmbientManager.TransitionDetails: the AmbientManager.TransitionDetails pertinent to the transition. |
finishNotifier |
AmbientManager.AmbientTransitionFinishedNotifier: an instance of the AmbientTransitionFinishedNotifier that
can be used to signal early finish to the system. |