|
@@ -1,5 +1,7 @@
|
1
|
1
|
package com.reactnativenavigation.react;
|
2
|
2
|
|
|
3
|
+import android.support.annotation.NonNull;
|
|
4
|
+
|
3
|
5
|
import com.facebook.react.ReactInstanceManager;
|
4
|
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
5
|
7
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
@@ -17,7 +19,7 @@ import com.reactnativenavigation.viewcontrollers.ViewController;
|
17
|
19
|
public class NavigationModule extends ReactContextBaseJavaModule {
|
18
|
20
|
private static final String NAME = "RNNBridgeModule";
|
19
|
21
|
private final ReactInstanceManager reactInstanceManager;
|
20
|
|
- private Store store;
|
|
22
|
+ private final Store store;
|
21
|
23
|
|
22
|
24
|
public NavigationModule(final ReactApplicationContext reactContext, final ReactInstanceManager reactInstanceManager, final Store store) {
|
23
|
25
|
super(reactContext);
|
|
@@ -36,9 +38,8 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
36
|
38
|
@Override
|
37
|
39
|
public void run() {
|
38
|
40
|
final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
|
39
|
|
- LayoutFactory factory = new LayoutFactory(activity(), reactInstanceManager, store);
|
40
|
|
- final ViewController rootView = factory.createAndSaveToStore(layoutTree);
|
41
|
|
- activity().setViewController(rootView);
|
|
41
|
+ final ViewController viewController = newLayoutFactory().createAndSaveToStore(layoutTree);
|
|
42
|
+ activity().setViewController(viewController);
|
42
|
43
|
}
|
43
|
44
|
});
|
44
|
45
|
}
|
|
@@ -49,9 +50,8 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
49
|
50
|
@Override
|
50
|
51
|
public void run() {
|
51
|
52
|
final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
|
52
|
|
- LayoutFactory factory = new LayoutFactory(activity(), reactInstanceManager, store);
|
53
|
|
- final ViewController rootView = factory.createAndSaveToStore(layoutTree);
|
54
|
|
- store.getViewController(onContainerId).getStackController().push(rootView);
|
|
53
|
+ final ViewController viewController = newLayoutFactory().createAndSaveToStore(layoutTree);
|
|
54
|
+ store.getViewController(onContainerId).getStackController().push(viewController);
|
55
|
55
|
}
|
56
|
56
|
});
|
57
|
57
|
}
|
|
@@ -61,16 +61,20 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
61
|
61
|
handle(new Runnable() {
|
62
|
62
|
@Override
|
63
|
63
|
public void run() {
|
64
|
|
- ViewController layout = store.getViewController(onContainerId);
|
65
|
|
- layout.getStackController().pop(layout);
|
|
64
|
+ store.getViewController(onContainerId).getStackController().pop(store.getViewController(onContainerId));
|
66
|
65
|
}
|
67
|
66
|
});
|
68
|
67
|
}
|
69
|
68
|
|
70
|
|
- NavigationActivity activity() {
|
|
69
|
+ private NavigationActivity activity() {
|
71
|
70
|
return (NavigationActivity) getCurrentActivity();
|
72
|
71
|
}
|
73
|
72
|
|
|
73
|
+ @NonNull
|
|
74
|
+ private LayoutFactory newLayoutFactory() {
|
|
75
|
+ return new LayoutFactory(activity(), reactInstanceManager, store);
|
|
76
|
+ }
|
|
77
|
+
|
74
|
78
|
private void handle(Runnable task) {
|
75
|
79
|
if (activity() == null) return;
|
76
|
80
|
UiThread.post(task);
|