|
@@ -1,6 +1,5 @@
|
1
|
1
|
package com.reactnativenavigation.controllers;
|
2
|
2
|
|
3
|
|
-import android.app.Activity;
|
4
|
3
|
import android.content.Intent;
|
5
|
4
|
import android.os.Bundle;
|
6
|
5
|
import android.support.v7.app.AppCompatActivity;
|
|
@@ -12,35 +11,34 @@ import com.reactnativenavigation.NavigationApplication;
|
12
|
11
|
import com.reactnativenavigation.layouts.Layout;
|
13
|
12
|
import com.reactnativenavigation.layouts.LayoutFactory;
|
14
|
13
|
import com.reactnativenavigation.params.ActivityParams;
|
15
|
|
-import com.reactnativenavigation.params.parsers.ActivityParamsParser;
|
|
14
|
+import com.reactnativenavigation.params.ScreenParams;
|
16
|
15
|
import com.reactnativenavigation.react.JsDevReloadHandler;
|
17
|
16
|
import com.reactnativenavigation.react.NavigationReactInstance;
|
18
|
17
|
import com.reactnativenavigation.react.RedboxPermission;
|
19
|
18
|
|
20
|
19
|
public class NavigationActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler, NavigationReactInstance.OnJsDevReloadListener {
|
21
|
20
|
|
22
|
|
- public static final String PARAMS_BUNDLE = "PARAMS_BUNDLE";
|
23
|
21
|
/**
|
24
|
22
|
* Although we start multiple activities, we make sure to pass Intent.CLEAR_TASK | Intent.NEW_TASK
|
25
|
23
|
* So that we actually have only 1 instance of the activity running at one time.
|
26
|
|
- * We hold the currentActivity (resume->pause) so we know when we need to destroy the javascript context.
|
27
|
|
- * This is somewhat weird, and in the future either fully support multiple activities,
|
28
|
|
- * OR a single activity with changing contentView similar to ReactNative impl.
|
|
24
|
+ * We hold the currentActivity (resume->pause) so we know when we need to destroy the javascript context
|
|
25
|
+ * (when currentActivity is null, ie pause and destroy was called without resume).
|
|
26
|
+ * This is somewhat weird, and in the future we better use a single activity with changing contentView similar to ReactNative impl.
|
|
27
|
+ * Along with that, we should handle commands from the bridge using onNewIntent
|
29
|
28
|
*/
|
30
|
|
- private static Activity currentActivity;
|
|
29
|
+ static NavigationActivity currentActivity;
|
|
30
|
+
|
|
31
|
+ private final ModalController modalController = new ModalController();
|
31
|
32
|
private ActivityParams activityParams;
|
32
|
|
- private ModalController modalController;
|
33
|
33
|
private Layout layout;
|
34
|
34
|
|
35
|
35
|
@Override
|
36
|
36
|
protected void onCreate(Bundle savedInstanceState) {
|
37
|
37
|
super.onCreate(savedInstanceState);
|
|
38
|
+ RedboxPermission.permissionToShowRedboxIfNeeded(this);
|
38
|
39
|
|
39
|
|
- activityParams = ActivityParamsParser.parse(getIntent().getBundleExtra(PARAMS_BUNDLE));
|
40
|
|
-
|
41
|
|
- modalController = new ModalController();
|
|
40
|
+ activityParams = NavigationCommandsHandler.getActivityParams(getIntent());
|
42
|
41
|
|
43
|
|
- RedboxPermission.permissionToShowRedboxIfNeeded(this);
|
44
|
42
|
createLayout();
|
45
|
43
|
}
|
46
|
44
|
|
|
@@ -107,4 +105,8 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
|
107
|
105
|
private NavigationReactInstance getNavigationReactInstance() {
|
108
|
106
|
return NavigationApplication.instance.getNavigationReactInstance();
|
109
|
107
|
}
|
|
108
|
+
|
|
109
|
+ void push(ScreenParams params) {
|
|
110
|
+ layout.push(params);
|
|
111
|
+ }
|
110
|
112
|
}
|