mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate ReactRoot to Kotlin (#53238)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53238 Changelog: [Android][Changed] - Migrated ReactRoot to Kotlin Reviewed By: cortinico Differential Revision: D80074359 fbshipit-source-id: 273f5bfc2826f59f2bb1521b8dbd95c48e5eb0c4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3774f75705
commit
0b14a19ea6
@@ -3806,6 +3806,7 @@ public abstract interface class com/facebook/react/uimanager/ReactPointerEventsV
|
||||
}
|
||||
|
||||
public abstract interface class com/facebook/react/uimanager/ReactRoot {
|
||||
public static final field Companion Lcom/facebook/react/uimanager/ReactRoot$Companion;
|
||||
public static final field STATE_STARTED I
|
||||
public static final field STATE_STOPPED I
|
||||
public abstract fun getAppProperties ()Landroid/os/Bundle;
|
||||
@@ -3823,6 +3824,11 @@ public abstract interface class com/facebook/react/uimanager/ReactRoot {
|
||||
public abstract fun setShouldLogContentAppeared (Z)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/uimanager/ReactRoot$Companion {
|
||||
public static final field STATE_STARTED I
|
||||
public static final field STATE_STOPPED I
|
||||
}
|
||||
|
||||
public abstract interface class com/facebook/react/uimanager/ReactShadowNode {
|
||||
public abstract fun addChildAt (Lcom/facebook/react/uimanager/ReactShadowNode;I)V
|
||||
public abstract fun addNativeChildAt (Lcom/facebook/react/uimanager/ReactShadowNode;I)V
|
||||
|
||||
-76
@@ -1,76 +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 android.os.Bundle;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
import com.facebook.react.uimanager.common.UIManagerType;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/** Interface for the root native view of a React native application */
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
public interface ReactRoot {
|
||||
|
||||
/** This constant represents that ReactRoot hasn't started yet or it has been destroyed. */
|
||||
int STATE_STOPPED = 0;
|
||||
|
||||
/** This constant represents that ReactRoot has started. */
|
||||
int STATE_STARTED = 1;
|
||||
|
||||
/** Return cached launch properties for app */
|
||||
@Nullable
|
||||
Bundle getAppProperties();
|
||||
|
||||
String getJSModuleName();
|
||||
|
||||
/** Fabric or Default UI Manager, see {@link UIManagerType} */
|
||||
@UIManagerType
|
||||
int getUIManagerType();
|
||||
|
||||
int getRootViewTag();
|
||||
|
||||
void setRootViewTag(int rootViewTag);
|
||||
|
||||
/** Calls into JS to start the React application. */
|
||||
void runApplication();
|
||||
|
||||
/** Handler for stages {@link com.facebook.react.surface.ReactStage} */
|
||||
void onStage(@ReactStage int stage);
|
||||
|
||||
/** Return native view for root */
|
||||
ViewGroup getRootViewGroup();
|
||||
|
||||
/**
|
||||
* @return Cached values for widthMeasureSpec.
|
||||
*/
|
||||
int getWidthMeasureSpec();
|
||||
|
||||
/**
|
||||
* @return Cached values for and heightMeasureSpec.
|
||||
*/
|
||||
int getHeightMeasureSpec();
|
||||
|
||||
/** Sets a flag that determines whether to log that content appeared on next view added. */
|
||||
void setShouldLogContentAppeared(boolean shouldLogContentAppeared);
|
||||
|
||||
/**
|
||||
* @return a {@link String} that represents the root js application that is being rendered with
|
||||
* this {@link ReactRoot}
|
||||
* @deprecated We recommend to not use this method as it is will be replaced in the near future.
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
String getSurfaceID();
|
||||
|
||||
/**
|
||||
* @return an {@link AtomicInteger} that represents the state of the ReactRoot object.
|
||||
*/
|
||||
AtomicInteger getState();
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 android.os.Bundle
|
||||
import android.view.ViewGroup
|
||||
import com.facebook.react.uimanager.common.UIManagerType
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
/** Interface for the root native view of a React native application */
|
||||
public interface ReactRoot {
|
||||
|
||||
public companion object {
|
||||
/** This constant represents that ReactRoot hasn't started yet or it has been destroyed. */
|
||||
public const val STATE_STOPPED: Int = 0
|
||||
|
||||
/** This constant represents that ReactRoot has started. */
|
||||
public const val STATE_STARTED: Int = 1
|
||||
}
|
||||
|
||||
/** Return cached launch properties for app */
|
||||
public fun getAppProperties(): Bundle?
|
||||
|
||||
public fun getJSModuleName(): String
|
||||
|
||||
/** Fabric or Default UI Manager, see [UIManagerType] */
|
||||
@UIManagerType public fun getUIManagerType(): Int
|
||||
|
||||
public fun getRootViewTag(): Int
|
||||
|
||||
public fun setRootViewTag(rootViewTag: Int)
|
||||
|
||||
/** Calls into JS to start the React application. */
|
||||
public fun runApplication()
|
||||
|
||||
/** Handler for stages [com.facebook.react.surface.ReactStage] */
|
||||
public fun onStage(@ReactStage stage: Int)
|
||||
|
||||
/** Return native view for root */
|
||||
public fun getRootViewGroup(): ViewGroup
|
||||
|
||||
/** @return Cached values for widthMeasureSpec. */
|
||||
public fun getWidthMeasureSpec(): Int
|
||||
|
||||
/** @return Cached values for and heightMeasureSpec. */
|
||||
public fun getHeightMeasureSpec(): Int
|
||||
|
||||
/** Sets a flag that determines whether to log that content appeared on next view added. */
|
||||
public fun setShouldLogContentAppeared(shouldLogContentAppeared: Boolean)
|
||||
|
||||
/**
|
||||
* @return a [String] that represents the root js application that is being rendered with this
|
||||
* [ReactRoot]
|
||||
* @deprecated We recommend to not use this method as it is will be replaced in the near future.
|
||||
*/
|
||||
@Deprecated("We recommend to not use this method as it is will be replaced in the near future.")
|
||||
public fun getSurfaceID(): String?
|
||||
|
||||
/** @return an [AtomicInteger] that represents the state of the ReactRoot object. */
|
||||
public fun getState(): AtomicInteger
|
||||
}
|
||||
+2
-1
@@ -194,7 +194,8 @@ public object UIManagerHelper {
|
||||
public fun getSurfaceId(view: View): Int {
|
||||
if (view is ReactRoot) {
|
||||
val rootView = view as ReactRoot
|
||||
return if (rootView.uiManagerType == UIManagerType.FABRIC) rootView.rootViewTag else -1
|
||||
return if (rootView.getUIManagerType() == UIManagerType.FABRIC) rootView.getRootViewTag()
|
||||
else -1
|
||||
}
|
||||
|
||||
val reactTag = view.id
|
||||
|
||||
@@ -98,7 +98,7 @@ class RootViewTest {
|
||||
val rootViewId = 11
|
||||
val rootView = ReactRootView(reactContext)
|
||||
rootView.id = rootViewId
|
||||
rootView.rootViewTag = rootViewId
|
||||
rootView.setRootViewTag(rootViewId)
|
||||
rootView.startReactApplication(instanceManager, "")
|
||||
rootView.simulateAttachForTesting()
|
||||
val ts = SystemClock.currentTimeMillis()
|
||||
|
||||
Reference in New Issue
Block a user