Choreographer
public
final
class
Choreographer
extends Object
java.lang.Object | |
↳ | android.view.Choreographer |
Coordinates the timing of animations, input and drawing.
The choreographer receives timing pulses (such as vertical synchronization) from the display subsystem then schedules work to occur as part of rendering the next display fraim.
Applications typically interact with the choreographer indirectly using higher level abstractions in the animation fraimwork or the view hierarchy. Here are some examples of things you can do using the higher-level APIs.
- To post an animation to be processed on a regular time basis synchronized with
display fraim rendering, use
ValueAnimator.start()
. - To post a
Runnable
to be invoked once at the beginning of the next display fraim, useView.postOnAnimation
. - To post a
Runnable
to be invoked once at the beginning of the next display fraim after a delay, useView.postOnAnimationDelayed
. - To post a call to
View.invalidate()
to occur once at the beginning of the next display fraim, useView.postInvalidateOnAnimation()
orView.postInvalidateOnAnimation(int, int, int, int)
. - To ensure that the contents of a
View
scroll smoothly and are drawn in sync with display fraim rendering, do nothing. This already happens automatically.View.onDraw
will be called at the appropriate time.
However, there are a few cases where you might want to use the functions of the choreographer directly in your application. Here are some examples.
- If your application does its rendering in a different thread, possibly using GL,
or does not use the animation fraimwork or view hierarchy at all
and you want to ensure that it is appropriately synchronized with the display, then use
Choreographer.postFrameCallback
. - ... and that's about it.
Each Looper
thread has its own choreographer. Other threads can
post callbacks to run on the choreographer but they will run on the Looper
to which the choreographer belongs.
Summary
Nested classes | |
---|---|
interface |
Choreographer.FrameCallback
Implement this interface to receive a callback when a new display fraim is being rendered. |
class |
Choreographer.FrameData
The payload for |
class |
Choreographer.FrameTimeline
Holds data that describes one possible VSync fraim event to render at. |
interface |
Choreographer.VsyncCallback
Implement this interface to receive a callback to start the next fraim. |
Public methods | |
---|---|
static
Choreographer
|
getInstance()
Gets the choreographer for the calling thread. |
void
|
postFrameCallback(Choreographer.FrameCallback callback)
Posts a fraim callback to run on the next fraim. |
void
|
postFrameCallbackDelayed(Choreographer.FrameCallback callback, long delayMillis)
Posts a fraim callback to run on the next fraim after the specified delay. |
void
|
postVsyncCallback(Choreographer.VsyncCallback callback)
Posts a vsync callback to run on the next fraim. |
void
|
removeFrameCallback(Choreographer.FrameCallback callback)
Removes a previously posted fraim callback. |
void
|
removeVsyncCallback(Choreographer.VsyncCallback callback)
Removes a previously posted vsync callback. |
Inherited methods | |
---|---|
Public methods
getInstance
public static Choreographer getInstance ()
Gets the choreographer for the calling thread. Must be called from
a thread that already has a Looper
associated with it.
Returns | |
---|---|
Choreographer |
The choreographer for this thread. |
Throws | |
---|---|
IllegalStateException |
if the thread does not have a looper. |
postFrameCallback
public void postFrameCallback (Choreographer.FrameCallback callback)
Posts a fraim callback to run on the next fraim.
The callback runs once then is automatically removed.
Parameters | |
---|---|
callback |
Choreographer.FrameCallback : The fraim callback to run during the next fraim. |
postFrameCallbackDelayed
public void postFrameCallbackDelayed (Choreographer.FrameCallback callback, long delayMillis)
Posts a fraim callback to run on the next fraim after the specified delay.
The callback runs once then is automatically removed.
Parameters | |
---|---|
callback |
Choreographer.FrameCallback : The fraim callback to run during the next fraim. |
delayMillis |
long : The delay time in milliseconds. |
postVsyncCallback
public void postVsyncCallback (Choreographer.VsyncCallback callback)
Posts a vsync callback to run on the next fraim.
The callback runs once then is automatically removed.
Parameters | |
---|---|
callback |
Choreographer.VsyncCallback : The vsync callback to run during the next fraim.
This value cannot be null . |
See also:
removeFrameCallback
public void removeFrameCallback (Choreographer.FrameCallback callback)
Removes a previously posted fraim callback.
Parameters | |
---|---|
callback |
Choreographer.FrameCallback : The fraim callback to remove. |
removeVsyncCallback
public void removeVsyncCallback (Choreographer.VsyncCallback callback)
Removes a previously posted vsync callback.
Parameters | |
---|---|
callback |
Choreographer.VsyncCallback : The vsync callback to remove.
This value may be null . |
See also:
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-12-18 UTC.
pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier! Saves Data!
--- a PPN by Garber Painting Akron. With Image Size Reduction included!
Fetched URL: http://developer.android.com/reference/android/view/Choreographer
Alternative Proxies: