Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
Ensure FrameCallbackFaceAnimationCallback uses the UI choreographer (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
renyu-io authored Jun 15, 2017
1 parent 5eed6d0 commit 6acda2f
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,13 @@ protected void advanceAnimation(final long frameTimeMillis) {
private static class FrameCallbackFaceAnimationCallback extends KeyframesDrawableAnimationCallback
implements Choreographer.FrameCallback {

private final Choreographer mChoreographer;
private static Choreographer sUIChoreographer;

private FrameCallbackFaceAnimationCallback(
FrameListener listener,
int frameRate,
int frameCount) {
super(listener, frameRate, frameCount);
mChoreographer = Choreographer.getInstance();
}

@Override
Expand All @@ -222,12 +221,18 @@ public void doFrame(long frameTimeNanos) {

@Override
protected void postCallback() {
mChoreographer.postFrameCallback(this);
if (sUIChoreographer == null) {
sUIChoreographer = Choreographer.getInstance();
}
sUIChoreographer.postFrameCallback(this);
}

@Override
protected void cancelCallback() {
mChoreographer.removeFrameCallback(this);
if (sUIChoreographer == null) {
sUIChoreographer = Choreographer.getInstance();
}
sUIChoreographer.removeFrameCallback(this);
}
}

Expand Down

0 comments on commit 6acda2f

Please sign in to comment.