|
@@ -6,25 +6,28 @@ import com.reactnativenavigation.NavigationActivity;
|
6
|
6
|
import com.reactnativenavigation.layout.LayoutFactory;
|
7
|
7
|
import com.reactnativenavigation.layout.LayoutNode;
|
8
|
8
|
import com.reactnativenavigation.layout.StackLayout;
|
9
|
|
-import com.reactnativenavigation.react.NavigationReactRootViewCreator;
|
|
9
|
+import com.reactnativenavigation.react.ReactRootViewCreator;
|
10
|
10
|
|
11
|
11
|
import org.json.JSONObject;
|
12
|
12
|
|
13
|
13
|
public class CommandsHandler {
|
14
|
14
|
|
|
15
|
+ private final ReactRootViewCreator reactRootViewCreator;
|
|
16
|
+
|
|
17
|
+ public CommandsHandler(ReactRootViewCreator reactRootViewCreator) {
|
|
18
|
+ this.reactRootViewCreator = reactRootViewCreator;
|
|
19
|
+ }
|
|
20
|
+
|
15
|
21
|
public void setRoot(final NavigationActivity activity, final JSONObject layoutTree) {
|
16
|
22
|
final LayoutNode layoutTreeRoot = LayoutNode.parse(layoutTree);
|
17
|
|
- LayoutFactory factory =
|
18
|
|
- new LayoutFactory(activity, new NavigationReactRootViewCreator());
|
19
|
|
-
|
|
23
|
+ LayoutFactory factory = new LayoutFactory(activity, reactRootViewCreator);
|
20
|
24
|
final View rootView = factory.create(layoutTreeRoot);
|
21
|
25
|
activity.setContentView(rootView);
|
22
|
26
|
}
|
23
|
27
|
|
24
|
28
|
public void push(final NavigationActivity activity, String onContainerId, JSONObject layoutTree) {
|
25
|
29
|
final LayoutNode layoutNode = LayoutNode.parse(layoutTree);
|
26
|
|
- LayoutFactory factory =
|
27
|
|
- new LayoutFactory(activity, new NavigationReactRootViewCreator());
|
|
30
|
+ LayoutFactory factory = new LayoutFactory(activity, reactRootViewCreator);
|
28
|
31
|
final View rootView = factory.create(layoutNode);
|
29
|
32
|
((StackLayout) activity.getContentView()).push(rootView);
|
30
|
33
|
}
|