From 1bf89daf035f3647f65dc6bdaf380c24b73d53e5 Mon Sep 17 00:00:00 2001 From: Andrew Datsenko Date: Mon, 29 Jul 2024 06:29:23 -0700 Subject: [PATCH] xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventBeatManager.java (#45733) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45733 Reviewed By: cortinico Differential Revision: D60233799 fbshipit-source-id: 61ebdb2833edbb29e7e4648e5c2ad2d560a47966 --- .../react/fabric/events/EventBeatManager.java | 48 ------------------- .../react/fabric/events/EventBeatManager.kt | 43 +++++++++++++++++ 2 files changed, 43 insertions(+), 48 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventBeatManager.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventBeatManager.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventBeatManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventBeatManager.java deleted file mode 100644 index 63a3e0c38c5..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventBeatManager.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.events; - -import android.annotation.SuppressLint; -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.jni.HybridData; -import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.fabric.FabricSoLoader; -import com.facebook.react.uimanager.events.BatchEventDispatchedListener; - -/** - * Class that acts as a proxy between the list of EventBeats registered in C++ and the Android side. - */ -@Nullsafe(Nullsafe.Mode.LOCAL) -@SuppressLint("MissingNativeLoadLibrary") -public final class EventBeatManager implements BatchEventDispatchedListener { - - static { - FabricSoLoader.staticInit(); - } - - @DoNotStrip private final HybridData mHybridData; - - private static native HybridData initHybrid(); - - private native void tick(); - - @Deprecated(forRemoval = true, since = "Deprecated on v0.72.0 Use EventBeatManager() instead") - public EventBeatManager(ReactApplicationContext reactApplicationContext) { - this(); - } - - public EventBeatManager() { - mHybridData = initHybrid(); - } - - @Override - public void onBatchEventDispatched() { - tick(); - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventBeatManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventBeatManager.kt new file mode 100644 index 00000000000..62f09aa30d9 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventBeatManager.kt @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.fabric.events + +import android.annotation.SuppressLint +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.facebook.react.bridge.ReactApplicationContext +import com.facebook.react.fabric.FabricSoLoader +import com.facebook.react.uimanager.events.BatchEventDispatchedListener + +/** + * Class that acts as a proxy between the list of EventBeats registered in C++ and the Android side. + */ +@SuppressLint("MissingNativeLoadLibrary") +@DoNotStrip +public final class EventBeatManager() : BatchEventDispatchedListener { + + @Suppress("NoHungarianNotation") @DoNotStrip private val mHybridData: HybridData = initHybrid() + + private external fun tick() + + @Deprecated("Deprecated on v0.72.0 Use EventBeatManager() instead") + @Suppress("UNUSED_PARAMETER") + public constructor(reactApplicationContext: ReactApplicationContext?) : this() + + override public fun onBatchEventDispatched() { + tick() + } + + private companion object { + init { + FabricSoLoader.staticInit() + } + + @JvmStatic private external fun initHybrid(): HybridData + } +}