Kotlinify ReactRootViewTagGenerator (#43771)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43771

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: cortinico

Differential Revision: D55637406

fbshipit-source-id: e66690a1f10d7825f27e060d6f434544b5f8c39d
This commit is contained in:
Fabrizio Cucci
2024-04-02 16:17:39 -07:00
committed by Facebook GitHub Bot
parent 79fa565b8c
commit cb28372c72
3 changed files with 25 additions and 30 deletions
@@ -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 <init> ()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 {
@@ -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;
}
}
@@ -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 }
}