Cache the instance of `ChoreographerCompat`

Summary:
Since `ChoreographerCompat.getInstance()` is a singleton, we cache its instance.

This will be important in a subsequent diff where we ensure that `ChoreographerCompat.getInstance()` is only called on the UI thread

Reviewed By: achen1

Differential Revision: D9169298

fbshipit-source-id: 2067a50770dd41f5b1a12b62b6a9f8fea83d91e8
This commit is contained in:
Ram N 2018-10-03 13:39:13 -07:00 коммит произвёл Facebook Github Bot
Родитель a5f3571770
Коммит 7f6254be43
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -7,6 +7,7 @@
package com.facebook.react.testing.idledetection;
import android.view.Choreographer;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -55,7 +56,8 @@ public class ReactIdleDetectionUtil {
new Runnable() {
@Override
public void run() {
ChoreographerCompat.getInstance().postFrameCallback(
final ChoreographerCompat choreographerCompat = ChoreographerCompat.getInstance();
choreographerCompat.postFrameCallback(
new ChoreographerCompat.FrameCallback() {
private int frameCount = 0;
@ -66,7 +68,7 @@ public class ReactIdleDetectionUtil {
if (frameCount == waitFrameCount) {
latch.countDown();
} else {
ChoreographerCompat.getInstance().postFrameCallback(this);
choreographerCompat.postFrameCallback(this);
}
}
});