2022-11-24 23:10:27 +01:00
|
|
|
package android.view;
|
|
|
|
|
|
|
|
|
|
public final class Choreographer {
|
2022-12-31 17:00:27 +01:00
|
|
|
public static interface FrameCallback {
|
2023-06-22 11:45:46 +02:00
|
|
|
public void doFrame(long frametime_in_nanoseconds);
|
2022-12-31 17:00:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Choreographer getInstance() {
|
|
|
|
|
return new Choreographer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void postFrameCallback(Choreographer.FrameCallback callback) {
|
|
|
|
|
postFrameCallbackDelayed(callback, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void postFrameCallbackDelayed(final Choreographer.FrameCallback callback, long delayMillis) {
|
|
|
|
|
// TODO - do the delay part
|
|
|
|
|
// NOTE: if we do this synchronously, it gets stuck
|
|
|
|
|
Thread async = new Thread(new Runnable() {
|
|
|
|
|
public void run() {
|
|
|
|
|
callback.doFrame(System.nanoTime());
|
2023-06-22 11:45:46 +02:00
|
|
|
} });
|
2022-12-31 17:00:27 +01:00
|
|
|
async.start();
|
|
|
|
|
}
|
2022-11-24 23:10:27 +01:00
|
|
|
}
|