diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index f916c4f2f09..54cc8a7c1c6 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -4456,9 +4456,9 @@ public abstract interface class com/facebook/react/uimanager/ReactRoot { public abstract fun setShouldLogContentAppeared (Z)V } -public class com/facebook/react/uimanager/ReactRootViewTagGenerator { - public fun ()V - public static fun getNextRootViewTag ()I +public final class com/facebook/react/uimanager/ReactRootViewTagGenerator { + public static final field INSTANCE Lcom/facebook/react/uimanager/ReactRootViewTagGenerator; + public static final fun getNextRootViewTag ()I } public abstract interface class com/facebook/react/uimanager/ReactShadowNode { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.java deleted file mode 100644 index 6c128e202ec..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.java +++ /dev/null @@ -1,27 +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.uimanager; - -import com.facebook.infer.annotation.Nullsafe; - -/** Incremental counter for React Root View tag. */ -@Nullsafe(Nullsafe.Mode.LOCAL) -public class ReactRootViewTagGenerator { - - // Keep in sync with ReactIOSTagHandles JS module - see that file for an explanation on why the - // increment here is 10. - private static final int ROOT_VIEW_TAG_INCREMENT = 10; - - private static int sNextRootViewTag = 1; - - public static synchronized int getNextRootViewTag() { - final int tag = sNextRootViewTag; - sNextRootViewTag += ROOT_VIEW_TAG_INCREMENT; - return tag; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.kt new file mode 100644 index 00000000000..20081d8b0cc --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.kt @@ -0,0 +1,22 @@ +/* + * 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.uimanager + +/** Incremental counter for React Root View tag. */ +public object ReactRootViewTagGenerator { + + // Keep in sync with ReactIOSTagHandles JS module - see that file for an explanation on why the + // increment here is 10. + private const val ROOT_VIEW_TAG_INCREMENT = 10 + private var nextRootViewTag = 1 + + @JvmStatic + @Synchronized + public fun getNextRootViewTag(): Int = + nextRootViewTag.also { nextRootViewTag += ROOT_VIEW_TAG_INCREMENT } +}