mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
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:
committed by
Facebook Github Bot
parent
a5f3571770
commit
7f6254be43
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user