Make Pip usage of FrameCallbackScheduler an actual class

Bug: 175330528
Test: Builds with new dynamic-animation library
Change-Id: I1632bd87a0f02940317a38a87b074d303f80b8c7
Merged-In: I1632bd87a0f02940317a38a87b074d303f80b8c7
(cherry picked from commit c6c603078b)
This commit is contained in:
Winson Chung
2021-01-07 15:45:27 -08:00
committed by Colin Cross
parent 9144eaf12f
commit 5a9716fa45

View File

@@ -23,6 +23,7 @@ import android.content.Context;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Debug;
import android.os.Looper;
import android.util.Log;
import android.view.Choreographer;
@@ -94,8 +95,18 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
private ThreadLocal<AnimationHandler> mSfAnimationHandlerThreadLocal =
ThreadLocal.withInitial(() -> {
FrameCallbackScheduler scheduler = runnable ->
final Looper initialLooper = Looper.myLooper();
final FrameCallbackScheduler scheduler = new FrameCallbackScheduler() {
@Override
public void postFrameCallback(@androidx.annotation.NonNull Runnable runnable) {
Choreographer.getSfInstance().postFrameCallback(t -> runnable.run());
}
@Override
public boolean isCurrentThread() {
return Looper.myLooper() == initialLooper;
}
};
AnimationHandler handler = new AnimationHandler(scheduler);
return handler;
});