mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-08 09:37:21 +08:00
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
This commit is contained in:
committed by
Facebook Github Bot 1
parent
deb0d60c09
commit
baf5a5b99a
@@ -16,6 +16,8 @@ import java.util.List;
|
||||
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 @@ public abstract class ReactNativeHost {
|
||||
.setApplication(mApplication)
|
||||
.setJSMainModuleName(getJSMainModuleName())
|
||||
.setUseDeveloperSupport(getUseDeveloperSupport())
|
||||
.setRedBoxHandler(getRedBoxHandler())
|
||||
.setUIImplementationProvider(getUIImplementationProvider())
|
||||
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE);
|
||||
|
||||
for (ReactPackage reactPackage : getPackages()) {
|
||||
@@ -76,10 +80,26 @@ public abstract class ReactNativeHost {
|
||||
} 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.
|
||||
|
||||
Reference in New Issue
Block a user