|
@@ -1,7 +1,6 @@
|
1
|
1
|
package com.reactnativenavigation.core;
|
2
|
2
|
|
3
|
3
|
import android.app.Application;
|
4
|
|
-import android.content.Context;
|
5
|
4
|
|
6
|
5
|
import com.facebook.react.LifecycleState;
|
7
|
6
|
import com.facebook.react.ReactInstanceManager;
|
|
@@ -9,10 +8,9 @@ import com.facebook.react.ReactPackage;
|
9
|
8
|
import com.facebook.react.bridge.ReactContext;
|
10
|
9
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
11
|
10
|
import com.facebook.react.bridge.WritableMap;
|
|
11
|
+import com.reactnativenavigation.activities.BaseReactActivity;
|
12
|
12
|
import com.reactnativenavigation.core.objects.Screen;
|
13
|
13
|
|
14
|
|
-import java.util.List;
|
15
|
|
-
|
16
|
14
|
import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
|
17
|
15
|
|
18
|
16
|
/**
|
|
@@ -23,7 +21,6 @@ public class RctManager {
|
23
|
21
|
private static RctManager sInstance;
|
24
|
22
|
|
25
|
23
|
private ReactInstanceManager mReactManager;
|
26
|
|
- private boolean mUseLocalDevServer = true;
|
27
|
24
|
|
28
|
25
|
private RctManager() {
|
29
|
26
|
// Singleton
|
|
@@ -44,38 +41,30 @@ public class RctManager {
|
44
|
41
|
return mReactManager != null;
|
45
|
42
|
}
|
46
|
43
|
|
47
|
|
- public void init(Context context, String componentName, List<ReactPackage> packages) {
|
48
|
|
- createReactInstanceManager(context, componentName, packages);
|
|
44
|
+ public void init(BaseReactActivity context) {
|
|
45
|
+ createReactInstanceManager(context);
|
49
|
46
|
}
|
50
|
47
|
|
51
|
48
|
/**
|
52
|
49
|
* Creates a React Instance Manager associated with this component name
|
53
|
|
- * @param context
|
54
|
|
- * @param jsBundleName
|
55
|
|
- * @param packages
|
56
|
50
|
*/
|
57
|
|
- public ReactInstanceManager createReactInstanceManager(Context context, String jsBundleName, List<ReactPackage> packages) {
|
58
|
|
- // Get component name
|
|
51
|
+ public ReactInstanceManager createReactInstanceManager(BaseReactActivity reactActivity) {
|
59
|
52
|
ReactInstanceManager.Builder builder = ReactInstanceManager.builder()
|
60
|
|
- .setApplication((Application) context.getApplicationContext())
|
61
|
|
- .setUseDeveloperSupport(true)
|
|
53
|
+ .setApplication((Application) reactActivity.getApplicationContext())
|
|
54
|
+ .setJSMainModuleName(reactActivity.getJSMainModuleName())
|
|
55
|
+ .setUseDeveloperSupport(reactActivity.getUseDeveloperSupport())
|
62
|
56
|
.setInitialLifecycleState(LifecycleState.BEFORE_RESUME);
|
63
|
|
- for (ReactPackage reactPackage : packages) {
|
|
57
|
+
|
|
58
|
+ for (ReactPackage reactPackage : reactActivity.getPackages()) {
|
64
|
59
|
builder.addPackage(reactPackage);
|
65
|
60
|
}
|
66
|
|
- if (mUseLocalDevServer) {
|
67
|
|
- // Set module name to be loaded from local node server
|
68
|
|
- builder.setJSMainModuleName("index.android");
|
69
|
|
- builder.setBundleAssetName("index.android.bundle");
|
|
61
|
+
|
|
62
|
+ String jsBundleFile = reactActivity.getJSBundleFile();
|
|
63
|
+
|
|
64
|
+ if (jsBundleFile != null) {
|
|
65
|
+ builder.setJSBundleFile(jsBundleFile);
|
70
|
66
|
} else {
|
71
|
|
- throw new RuntimeException("Implement me!");
|
72
|
|
- // // Get the bundle uri
|
73
|
|
- // String confResourceName = AssetManager.getConfUrlResourceName(jsBundleName);
|
74
|
|
- // Context context = AppDelegate.sharedApplication().getApplicationContext();
|
75
|
|
- // Uri uri =
|
76
|
|
- // AssetManager.sharedAssetManager().getConfResourceUrl(confResourceName, context);
|
77
|
|
- // // Load bundled jsBundle
|
78
|
|
- // builder.setJSBundleFile(uri.getPath());
|
|
67
|
+ builder.setBundleAssetName(reactActivity.getBundleAssetName());
|
79
|
68
|
}
|
80
|
69
|
|
81
|
70
|
mReactManager = builder.build();
|