mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-16 12:12:20 +08:00
mostly working on Android + OTA
Summary: It works great on iOS, and mostly works on Android, and is now OTA'able as part of the screen config! Haven't done template view yet. One remaining issue: Layout is borked on Android. I'm guessing the issue has to do with the timing of setting the constraints in `updateRootLayoutSpecs` and calling `mBinding.startSurface` which actually builds the shadow tree. If I try to call `updateRootLayoutSpecs` earlier, it just crashes immediately. Here's the layout it spits out, which clearly has -440 for the x of 420006, which is the RCTText component, causing it to get cut off on the left of the screen: ``` updateLayoutMountItem for reactTag: 420006 x: -440, y: -13, width: 931, height: 78 updateLayoutMountItem for reactTag: 420010 x: 26, y: 79, width: 0, height: 1651 updateLayoutMountItem for reactTag: 420012 x: 0, y: 26, width: 0, height: 158 updateLayoutMountItem for reactTag: 420016 x: 0, y: 210, width: 454, height: 454 updateLayoutMountItem for reactTag: 420018 x: 454, y: 210, width: 455, height: 454 updateLayoutMountItem for reactTag: 420022 x: 0, y: 690, width: 454, height: 454 updateLayoutMountItem for reactTag: 420024 x: 454, y: 690, width: 455, height: 454 updateLayoutMountItem for reactTag: 420028 x: 0, y: 1171, width: 454, height: 454 updateLayoutMountItem for reactTag: 420030 x: 454, y: 1171, width: 455, height: 454 updateLayoutMountItem for reactTag: 420032 x: 0, y: 1651, width: 0, height: 0 ``` Reviewed By: mdvacca Differential Revision: D12813192 fbshipit-source-id: 450d646af4883ff25184141721351da67b091b7c
This commit is contained in:
committed by
Facebook Github Bot
parent
aab01608ba
commit
7b5277bb75
@@ -35,6 +35,7 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.util.Log;
|
||||
@@ -45,6 +46,7 @@ import com.facebook.debug.tags.ReactDebugOverlayTags;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.infer.annotation.ThreadConfined;
|
||||
import com.facebook.infer.annotation.ThreadSafe;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.CatalystInstance;
|
||||
import com.facebook.react.bridge.CatalystInstanceImpl;
|
||||
import com.facebook.react.bridge.JSBundleLoader;
|
||||
@@ -63,6 +65,7 @@ import com.facebook.react.bridge.ReactMarker;
|
||||
import com.facebook.react.bridge.ReactMarkerConstants;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.bridge.WritableNativeMap;
|
||||
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
|
||||
import com.facebook.react.common.LifecycleState;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
@@ -1033,7 +1036,12 @@ public class ReactInstanceManager {
|
||||
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachRootViewToInstance");
|
||||
UIManager uiManagerModule = UIManagerHelper.getUIManager(mCurrentReactContext, rootView.getUIManagerType());
|
||||
|
||||
final int rootTag = uiManagerModule.addRootView(rootView);
|
||||
@Nullable Bundle initialProperties = rootView.getAppProperties();
|
||||
final int rootTag = uiManagerModule.addRootView(
|
||||
rootView,
|
||||
initialProperties == null ?
|
||||
new WritableNativeMap() : Arguments.fromBundle(initialProperties),
|
||||
rootView.getInitialUITemplate());
|
||||
rootView.setRootViewTag(rootTag);
|
||||
rootView.runApplication();
|
||||
Systrace.beginAsyncSection(
|
||||
|
||||
@@ -82,6 +82,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout
|
||||
private @Nullable ReactInstanceManager mReactInstanceManager;
|
||||
private @Nullable String mJSModuleName;
|
||||
private @Nullable Bundle mAppProperties;
|
||||
private @Nullable String mInitialUITemplate;
|
||||
private @Nullable CustomGlobalLayoutListener mCustomGlobalLayoutListener;
|
||||
private @Nullable ReactRootViewEventListener mRootViewEventListener;
|
||||
private int mRootViewTag;
|
||||
@@ -343,6 +344,13 @@ public class ReactRootView extends SizeMonitoringFrameLayout
|
||||
startReactApplication(reactInstanceManager, moduleName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@see #startReactApplication(ReactInstanceManager, String, android.os.Bundle, String)}
|
||||
*/
|
||||
public void startReactApplication(ReactInstanceManager reactInstanceManager, String moduleName, @Nullable Bundle initialProperties) {
|
||||
startReactApplication(reactInstanceManager, moduleName, initialProperties, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule rendering of the react component rendered by the JS application from the given JS
|
||||
* module (@{param moduleName}) using provided {@param reactInstanceManager} to attach to the
|
||||
@@ -352,7 +360,8 @@ public class ReactRootView extends SizeMonitoringFrameLayout
|
||||
public void startReactApplication(
|
||||
ReactInstanceManager reactInstanceManager,
|
||||
String moduleName,
|
||||
@Nullable Bundle initialProperties) {
|
||||
@Nullable Bundle initialProperties,
|
||||
@Nullable String initialUITemplate) {
|
||||
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "startReactApplication");
|
||||
try {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
@@ -367,6 +376,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout
|
||||
mReactInstanceManager = reactInstanceManager;
|
||||
mJSModuleName = moduleName;
|
||||
mAppProperties = initialProperties;
|
||||
mInitialUITemplate = initialUITemplate;
|
||||
|
||||
if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {
|
||||
mReactInstanceManager.createReactContextInBackground();
|
||||
@@ -449,6 +459,10 @@ public class ReactRootView extends SizeMonitoringFrameLayout
|
||||
return mAppProperties;
|
||||
}
|
||||
|
||||
public @Nullable String getInitialUITemplate() {
|
||||
return mInitialUITemplate;
|
||||
}
|
||||
|
||||
public void setAppProperties(@Nullable Bundle appProperties) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
mAppProperties = appProperties;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.facebook.react.bridge;
|
||||
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.uimanager.common.MeasureSpecProvider;
|
||||
import com.facebook.react.uimanager.common.SizeMonitoringFrameLayout;
|
||||
|
||||
@@ -17,7 +18,7 @@ public interface UIManager extends JSIModule, PerformanceCounter {
|
||||
/**
|
||||
* Registers a new root view.
|
||||
*/
|
||||
<T extends SizeMonitoringFrameLayout & MeasureSpecProvider> int addRootView(final T rootView);
|
||||
<T extends SizeMonitoringFrameLayout & MeasureSpecProvider> int addRootView(final T rootView, WritableMap initialProps, @Nullable String initialUITemplate);
|
||||
|
||||
/**
|
||||
* Unregisters a new root view.
|
||||
|
||||
@@ -363,6 +363,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
||||
return mUIImplementation.getProfiledBatchPerfCounters();
|
||||
}
|
||||
|
||||
public <T extends SizeMonitoringFrameLayout & MeasureSpecProvider> int addRootView(
|
||||
final T rootView) {
|
||||
return addRootView(rootView, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new root view. JS can use the returned tag with manageChildren to add/remove
|
||||
* children to this view.
|
||||
@@ -374,7 +379,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
||||
*/
|
||||
@Override
|
||||
public <T extends SizeMonitoringFrameLayout & MeasureSpecProvider> int addRootView(
|
||||
final T rootView) {
|
||||
final T rootView, WritableMap initialProps, @Nullable String initialUITemplate) {
|
||||
Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIManagerModule.addRootView");
|
||||
final int tag = ReactRootViewTagGenerator.getNextRootViewTag();
|
||||
final ReactApplicationContext reactApplicationContext = getReactApplicationContext();
|
||||
|
||||
Reference in New Issue
Block a user