public abstract class

WindowInsetsAnimationCompat.Callback

extends java.lang.Object

 java.lang.Object

↳androidx.core.view.WindowInsetsAnimationCompat.Callback

Overview

Interface that allows the application to listen to animation events for windows that cause insets.

Summary

Fields
public static final intDISPATCH_MODE_CONTINUE_ON_SUBTREE

Return value for WindowInsetsAnimationCompat.Callback.getDispatchMode(): Dispatching of animation events should continue in the view hierarchy.

public static final intDISPATCH_MODE_STOP

Return value for WindowInsetsAnimationCompat.Callback.getDispatchMode(): Dispatching of animation events should stop at this level in the view hierarchy, and no animation events should be dispatch to the subtree of the view hierarchy.

Constructors
publicCallback(int dispatchMode)

Creates a new WindowInsetsAnimationCompat callback with the given dispatch mode.

Methods
public final intgetDispatchMode()

Retrieves the dispatch mode of this listener.

public voidonEnd(WindowInsetsAnimationCompat animation)

Called when an insets animation has ended.

public voidonPrepare(WindowInsetsAnimationCompat animation)

Called when an insets animation is about to start and before the views have been re-laid out due to an animation.

public abstract WindowInsetsCompatonProgress(WindowInsetsCompat insets, java.util.List<WindowInsetsAnimationCompat> runningAnimations)

Called when the insets change as part of running an animation.

public WindowInsetsAnimationCompat.BoundsCompatonStart(WindowInsetsAnimationCompat animation, WindowInsetsAnimationCompat.BoundsCompat bounds)

Called when an insets animation gets started.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final int DISPATCH_MODE_STOP

Return value for WindowInsetsAnimationCompat.Callback.getDispatchMode(): Dispatching of animation events should stop at this level in the view hierarchy, and no animation events should be dispatch to the subtree of the view hierarchy.

public static final int DISPATCH_MODE_CONTINUE_ON_SUBTREE

Return value for WindowInsetsAnimationCompat.Callback.getDispatchMode(): Dispatching of animation events should continue in the view hierarchy.

Constructors

public Callback(int dispatchMode)

Creates a new WindowInsetsAnimationCompat callback with the given dispatch mode.

Parameters:

dispatchMode: The dispatch mode for this callback. See WindowInsetsAnimationCompat.Callback.getDispatchMode().

Methods

public final int getDispatchMode()

Retrieves the dispatch mode of this listener. Dispatch of the all animation events is hierarchical: It will starts at the root of the view hierarchy and then traverse it and invoke the callback of the specific View that is being traversed. The method may return either WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE to indicate that animation events should be propagated to the subtree of the view hierarchy, or WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_STOP to stop dispatching. In that case, all animation callbacks related to the animation passed in will be stopped from propagating to the subtree of the hierarchy.

Also note that WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_STOP behaves the same way as returning WindowInsetsCompat.CONSUMED during the regular insets dispatch in View.

Returns:

Either WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE to indicate that dispatching of animation events will continue to the subtree of the view hierarchy, or WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_STOP to indicate that animation events will stop dispatching.

public void onPrepare(WindowInsetsAnimationCompat animation)

Called when an insets animation is about to start and before the views have been re-laid out due to an animation.

This ordering allows the application to inspect the end state after the animation has finished, and then revert to the starting state of the animation in the first WindowInsetsAnimationCompat.Callback.onProgress(WindowInsetsCompat, List) callback by using post-layout view properties like View and related methods.

The ordering of events during an insets animation is the following:

Note: If the animation is application controlled by using WindowInsetsControllerCompat.controlWindowInsetsAnimation(int, long, Interpolator, CancellationSignal, WindowInsetsAnimationControlListenerCompat), the end state of the animation is undefined as the application may decide on the end state only by passing in shown parameter when calling WindowInsetsAnimationControllerCompat.finish(boolean). In this situation, the system will dispatch the insets in the opposite visibility state before the animation starts. Example: When controlling the input method with WindowInsetsControllerCompat.controlWindowInsetsAnimation(int, long, Interpolator, CancellationSignal, WindowInsetsAnimationControlListenerCompat) and the input method is currently showing, View will receive a WindowInsetsCompat instance for which WindowInsetsCompat.isVisible(int) will return false for WindowInsetsCompat.Type.ime().

Parameters:

animation: The animation that is about to start.

Called when an insets animation gets started.

This ordering allows the application to inspect the end state after the animation has finished, and then revert to the starting state of the animation in the first WindowInsetsAnimationCompat.Callback.onProgress(WindowInsetsCompat, List) callback by using post-layout view properties like View and related methods.

The ordering of events during an insets animation is the following:

Note that, like WindowInsetsAnimationCompat.Callback.onProgress(WindowInsetsCompat, List), dispatch of the animation start event is hierarchical: It will starts at the root of the view hierarchy and then traverse it and invoke the callback of the specific View that is being traversed. The method may return a modified instance of the bounds by calling WindowInsetsAnimationCompat.BoundsCompat.inset(Insets) to indicate that a part of the insets have been used to offset or clip its children, and the children shouldn't worry about that part anymore. Furthermore, if WindowInsetsAnimationCompat.Callback.getDispatchMode() returns WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_STOP, children of this view will not receive the callback anymore.

Parameters:

animation: The animation that is about to start.
bounds: The bounds in which animation happens.

Returns:

The animation bounds representing the part of the insets that should be dispatched to the subtree of the hierarchy.

public abstract WindowInsetsCompat onProgress(WindowInsetsCompat insets, java.util.List<WindowInsetsAnimationCompat> runningAnimations)

Called when the insets change as part of running an animation. Note that even if multiple animations for different types are running, there will only be one progress callback per frame. The insets passed as an argument represents the overall state and will include all types, regardless of whether they are animating or not.

Note that insets dispatch is hierarchical: It will start at the root of the view hierarchy, and then traverse it and invoke the callback of the specific View being traversed. The method may return a modified instance by calling WindowInsetsCompat.inset(int, int, int, int) to indicate that a part of the insets have been used to offset or clip its children, and the children shouldn't worry about that part anymore. Furthermore, if WindowInsetsAnimationCompat.Callback.getDispatchMode() returns WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_STOP, children of this view will not receive the callback anymore.

Parameters:

insets: The current insets.
runningAnimations: The currently running animations.

Returns:

The insets to dispatch to the subtree of the hierarchy.

public void onEnd(WindowInsetsAnimationCompat animation)

Called when an insets animation has ended.

Parameters:

animation: The animation that has ended. This will be the same instance as passed into WindowInsetsAnimationCompat.Callback.onStart(WindowInsetsAnimationCompat, WindowInsetsAnimationCompat.BoundsCompat)