From 7f6254be43ead1a69e3b7d3cdb30a4be04933be6 Mon Sep 17 00:00:00 2001 From: Ram N Date: Wed, 3 Oct 2018 13:39:13 -0700 Subject: [PATCH] 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 --- .../react/testing/idledetection/ReactIdleDetectionUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactIdleDetectionUtil.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactIdleDetectionUtil.java index 2b95632c4f..c749cfef94 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactIdleDetectionUtil.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactIdleDetectionUtil.java @@ -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); } } });