|
@@ -17,6 +17,7 @@ import com.reactnativenavigation.params.TitleBarLeftButtonParams;
|
17
|
17
|
import com.reactnativenavigation.react.JsDevReloadHandler;
|
18
|
18
|
import com.reactnativenavigation.react.ReactGateway;
|
19
|
19
|
import com.reactnativenavigation.react.RedboxPermission;
|
|
20
|
+import com.reactnativenavigation.utils.IntentUtils;
|
20
|
21
|
|
21
|
22
|
import java.util.List;
|
22
|
23
|
|
|
@@ -35,14 +36,16 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
|
35
|
36
|
private ActivityParams activityParams;
|
36
|
37
|
private ModalController modalController;
|
37
|
38
|
private Layout layout;
|
|
39
|
+ private boolean waitingForNewJsContext = false;
|
38
|
40
|
|
39
|
41
|
@Override
|
40
|
42
|
protected void onCreate(Bundle savedInstanceState) {
|
41
|
43
|
super.onCreate(savedInstanceState);
|
42
|
44
|
|
43
|
45
|
if (!NavigationApplication.instance.isReactContextInitialized()) {
|
44
|
|
- NavigationApplication.instance.startReactContext();
|
|
46
|
+ waitingForNewJsContext = true;
|
45
|
47
|
finish();
|
|
48
|
+ startActivity(IntentUtils.getLauncherIntent());
|
46
|
49
|
return;
|
47
|
50
|
}
|
48
|
51
|
|
|
@@ -71,30 +74,36 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
|
71
|
74
|
}
|
72
|
75
|
|
73
|
76
|
currentActivity = this;
|
74
|
|
- NavigationApplication.instance.getReactGateway().onResume(this, this, this);
|
|
77
|
+ NavigationApplication.instance.getReactGateway().onResumeActivity(this, this, this);
|
75
|
78
|
}
|
76
|
79
|
|
77
|
80
|
@Override
|
78
|
81
|
protected void onPause() {
|
79
|
82
|
super.onPause();
|
80
|
83
|
currentActivity = null;
|
81
|
|
- NavigationApplication.instance.getReactGateway().onPause();
|
|
84
|
+ NavigationApplication.instance.getReactGateway().onPauseActivity();
|
82
|
85
|
}
|
83
|
86
|
|
84
|
87
|
@Override
|
85
|
88
|
protected void onDestroy() {
|
|
89
|
+ destroyLayouts();
|
|
90
|
+ destroyJsIfNeeded();
|
|
91
|
+ super.onDestroy();
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ private void destroyLayouts() {
|
86
|
95
|
if (modalController != null) {
|
87
|
96
|
modalController.destroy();
|
88
|
97
|
}
|
89
|
98
|
if (layout != null) {
|
90
|
99
|
layout.destroy();
|
91
|
100
|
}
|
92
|
|
- if (currentActivity == null || currentActivity.isFinishing()) {
|
93
|
|
- if (NavigationApplication.instance.isReactContextInitialized()) {
|
94
|
|
- NavigationApplication.instance.getReactGateway().onDestroyApp();
|
95
|
|
- }
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ private void destroyJsIfNeeded() {
|
|
104
|
+ if (!waitingForNewJsContext && (currentActivity == null || currentActivity.isFinishing())) {
|
|
105
|
+ NavigationApplication.instance.getReactGateway().onDestroyApp();
|
96
|
106
|
}
|
97
|
|
- super.onDestroy();
|
98
|
107
|
}
|
99
|
108
|
|
100
|
109
|
@Override
|