Permalink
Browse files

add RedBoxHandler & UIImplementation to ReactNativeHost

Summary: Allow overriding RedBoxHandler and UIImplementation in custom ReactNativeHost implementations.

Reviewed By: astreet

Differential Revision: D3655354

fbshipit-source-id: cc168613c75a8540e8a802ce33576b3b6a97749c
  • Loading branch information...
1 parent deb0d60 commit baf5a5b99ada29e615b8e95389d58f1a2f9807cd @foghina foghina committed with Facebook Github Bot 1 Aug 8, 2016
Showing with 21 additions and 1 deletion.
  1. +21 −1 ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java
@@ -16,6 +16,8 @@
import android.app.Application;
import com.facebook.infer.annotation.Assertions;
+import com.facebook.react.devsupport.RedBoxHandler;
+import com.facebook.react.uimanager.UIImplementationProvider;
/**
* Simple class that holds an instance of {@link ReactInstanceManager}. This can be used in your
@@ -64,6 +66,8 @@ protected ReactInstanceManager createReactInstanceManager() {
.setApplication(mApplication)
.setJSMainModuleName(getJSMainModuleName())
.setUseDeveloperSupport(getUseDeveloperSupport())
+ .setRedBoxHandler(getRedBoxHandler())
+ .setUIImplementationProvider(getUIImplementationProvider())
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE);
for (ReactPackage reactPackage : getPackages()) {
@@ -76,11 +80,27 @@ protected ReactInstanceManager createReactInstanceManager() {
} else {
builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
}
-
return builder.build();
}
/**
+ * Get the {@link RedBoxHandler} to send RedBox-related callbacks to.
+ */
+ protected @Nullable RedBoxHandler getRedBoxHandler() {
+ return null;
+ }
+
+ /**
+ * Get the {@link UIImplementationProvider} to use. Override this method if you want to use a
+ * custom UI implementation.
+ *
+ * Note: this is very advanced functionality, in 99% of cases you don't need to override this.
+ */
+ protected UIImplementationProvider getUIImplementationProvider() {
+ return new UIImplementationProvider();
+ }
+
+ /**
* Returns the name of the main module. Determines the URL used to fetch the JS bundle
* from the packager server. It is only used when dev support is enabled.
* This is the first file to be executed once the {@link ReactInstanceManager} is created.

0 comments on commit baf5a5b

Please sign in to comment.