|
@@ -11,6 +11,7 @@ import com.facebook.react.bridge.ReadableArray;
|
11
|
11
|
import com.facebook.react.bridge.ReadableMap;
|
12
|
12
|
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
13
|
13
|
import com.reactnativenavigation.controllers.NavigationActivity;
|
|
14
|
+import com.reactnativenavigation.controllers.NavigationApplication;
|
14
|
15
|
import com.reactnativenavigation.layout.LayoutFactory;
|
15
|
16
|
import com.reactnativenavigation.layout.LayoutNode;
|
16
|
17
|
import com.reactnativenavigation.layout.StackLayout;
|
|
@@ -21,10 +22,12 @@ import java.util.HashMap;
|
21
|
22
|
import java.util.Map;
|
22
|
23
|
|
23
|
24
|
public class NavigationModule extends ReactContextBaseJavaModule {
|
24
|
|
- public static final String NAME = "RNNBridgeModule";
|
|
25
|
+ private static final String NAME = "RNNBridgeModule";
|
|
26
|
+ private final NavigationActivity activity;
|
25
|
27
|
|
26
|
|
- public NavigationModule(ReactApplicationContext reactContext) {
|
27
|
|
- super(reactContext);
|
|
28
|
+ public NavigationModule(ReactApplicationContext context, NavigationActivity activity) {
|
|
29
|
+ super(context);
|
|
30
|
+ this.activity = activity;
|
28
|
31
|
}
|
29
|
32
|
|
30
|
33
|
@Override
|
|
@@ -34,30 +37,35 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
34
|
37
|
|
35
|
38
|
@ReactMethod
|
36
|
39
|
public void setRoot(final ReadableMap layoutTree) {
|
37
|
|
- getActivity().runOnUiThread(new Runnable() {
|
|
40
|
+ NavigationApplication.instance.runOnUiThread(new Runnable() {
|
38
|
41
|
@Override
|
39
|
42
|
public void run() {
|
40
|
|
- LayoutFactory factory =
|
41
|
|
- new LayoutFactory(getActivity(), new LayoutFactory.ReactRootViewCreator() {
|
42
|
|
- @Override
|
43
|
|
- public View create(String id, String name) {
|
44
|
|
- ReactRootView rootView = new ReactRootView(getActivity());
|
45
|
|
- Bundle opts = new Bundle();
|
46
|
|
- opts.putString("id", id);
|
47
|
|
- rootView.startReactApplication(getActivity().getHost().getReactInstanceManager(), name, opts);
|
48
|
|
- return rootView;
|
49
|
|
- }
|
50
|
|
- }, new BottomTabsCreator());
|
51
|
|
-
|
52
|
|
- final LayoutNode layoutTreeRoot = readableMapToLayoutNode(layoutTree);
|
53
|
|
- final View rootView = factory.create(layoutTreeRoot);
|
54
|
|
- getActivity().setContentView(rootView);
|
|
43
|
+ getActivity().runOnUiThread(new Runnable() {
|
|
44
|
+ @Override
|
|
45
|
+ public void run() {
|
|
46
|
+ LayoutFactory factory =
|
|
47
|
+ new LayoutFactory(getActivity(), new LayoutFactory.ReactRootViewCreator() {
|
|
48
|
+ @Override
|
|
49
|
+ public View create(String id, String name) {
|
|
50
|
+ ReactRootView rootView = new ReactRootView(getActivity());
|
|
51
|
+ Bundle opts = new Bundle();
|
|
52
|
+ opts.putString("id", id);
|
|
53
|
+ rootView.startReactApplication(getActivity().getHost().getReactInstanceManager(), name, opts);
|
|
54
|
+ return rootView;
|
|
55
|
+ }
|
|
56
|
+ }, new BottomTabsCreator());
|
|
57
|
+
|
|
58
|
+ final LayoutNode layoutTreeRoot = readableMapToLayoutNode(layoutTree);
|
|
59
|
+ final View rootView = factory.create(layoutTreeRoot);
|
|
60
|
+ getActivity().setContentView(rootView);
|
|
61
|
+ }
|
|
62
|
+ });
|
55
|
63
|
}
|
56
|
64
|
});
|
57
|
65
|
}
|
58
|
66
|
|
59
|
67
|
private NavigationActivity getActivity() {
|
60
|
|
- return (NavigationActivity) getCurrentActivity();
|
|
68
|
+ return activity;
|
61
|
69
|
}
|
62
|
70
|
|
63
|
71
|
@ReactMethod
|