Skip to content

Commit

Permalink
fbandroid/libraries/components/litho-rendercore-transitions/src/main/…
Browse files Browse the repository at this point in the history
…java/com/facebook/litho/choreographercompat/ChoreographerCompatImpl.java

Reviewed By: jocelynluizzi13

Differential Revision: D62630517

fbshipit-source-id: 45b942091519736dc849a661b3939f4f926e1178
  • Loading branch information
generatedunixname89002005287564 authored and facebook-github-bot committed Sep 13, 2024
1 parent 74da29c commit 3d71e48
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.os.Looper;
import android.view.Choreographer;
import androidx.annotation.VisibleForTesting;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.litho.WorkContinuationInstrumenter;
import com.facebook.rendercore.utils.ThreadUtils;
import javax.annotation.Nullable;
Expand All @@ -32,6 +33,7 @@
*
* <p>This code was taken from the facebook/rebound repository.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public class ChoreographerCompatImpl implements ChoreographerCompat {

private static final long ONE_FRAME_MILLIS = 17;
Expand All @@ -56,10 +58,12 @@ public static ChoreographerCompat getInstance() {
/** Set the ChoreographerCompat instance for tests. */
@VisibleForTesting
public static void setInstance(@Nullable ChoreographerCompat choreographerCompat) {
// NULLSAFE_FIXME[Field Not Nullable]
sInstance = choreographerCompat;
}

private final @Nullable Handler mHandler;
// NULLSAFE_FIXME[Field Not Initialized]
private Choreographer mChoreographer;

@VisibleForTesting
Expand Down Expand Up @@ -92,6 +96,7 @@ public void postFrameCallback(FrameCallback callbackWrapper) {
if (IS_JELLYBEAN_OR_HIGHER && mChoreographer != null) {
choreographerPostFrameCallback(callbackWrapper.getFrameCallback());
} else {
// NULLSAFE_FIXME[Nullable Dereference]
mHandler.postDelayed(callbackWrapper.getRunnable(), 0);
}
}
Expand All @@ -105,6 +110,7 @@ public void postFrameCallbackDelayed(FrameCallback callbackWrapper, long delayMi
if (IS_JELLYBEAN_OR_HIGHER && mChoreographer != null) {
choreographerPostFrameCallbackDelayed(callbackWrapper.getFrameCallback(), delayMillis);
} else {
// NULLSAFE_FIXME[Nullable Dereference]
mHandler.postDelayed(callbackWrapper.getRunnable(), delayMillis + ONE_FRAME_MILLIS);
}
}
Expand All @@ -116,6 +122,7 @@ public void removeFrameCallback(FrameCallback callbackWrapper) {
if (IS_JELLYBEAN_OR_HIGHER && mChoreographer != null) {
choreographerRemoveFrameCallback(callbackWrapper.getFrameCallback());
} else {
// NULLSAFE_FIXME[Nullable Dereference]
mHandler.removeCallbacks(callbackWrapper.getRunnable());
}
}
Expand Down

0 comments on commit 3d71e48

Please sign in to comment.