1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-11-02 14:23:10 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Allow custom instance manager

This commit is contained in:
sunnylqm
2020-03-13 13:13:37 +08:00
parent 7ecf879ac9
commit 6a031f598f
2 changed files with 16 additions and 2 deletions

View File

@@ -20,7 +20,8 @@ public class UpdateContext {
private File rootDir; private File rootDir;
private Executor executor; private Executor executor;
public static boolean DEBUG = false; public static boolean DEBUG = true;
private static ReactInstanceManager mReactInstanceManager;
public UpdateContext(Context context) { public UpdateContext(Context context) {
this.context = context; this.context = context;
@@ -160,6 +161,15 @@ public class UpdateContext {
this.clearUp(); this.clearUp();
} }
public static void setCustomInstanceManager(ReactInstanceManager instanceManager) {
mReactInstanceManager = instanceManager;
}
public ReactInstanceManager getCustomReactInstanceManager() {
return mReactInstanceManager;
}
public static String getBundleUrl(Context context) { public static String getBundleUrl(Context context) {
return new UpdateContext(context.getApplicationContext()).getBundleUrl(); return new UpdateContext(context.getApplicationContext()).getBundleUrl();
} }

View File

@@ -127,7 +127,11 @@ public class UpdateModule extends ReactContextBaseJavaModule{
updateContext.switchVersion(hash); updateContext.switchVersion(hash);
Activity activity = getCurrentActivity(); Activity activity = getCurrentActivity();
Application application = activity.getApplication(); Application application = activity.getApplication();
ReactInstanceManager instanceManager = ((ReactApplication) application).getReactNativeHost().getReactInstanceManager(); ReactInstanceManager instanceManager = updateContext.getCustomReactInstanceManager();
if (instanceManager == null) {
instanceManager = ((ReactApplication) application).getReactNativeHost().getReactInstanceManager();
}
try { try {
Field jsBundleField = instanceManager.getClass().getDeclaredField("mJSBundleFile"); Field jsBundleField = instanceManager.getClass().getDeclaredField("mJSBundleFile");