|
@@ -6,6 +6,7 @@ import android.support.v7.app.AppCompatActivity;
|
6
|
6
|
import com.facebook.react.ReactInstanceManager;
|
7
|
7
|
import com.facebook.react.ReactNativeHost;
|
8
|
8
|
import com.facebook.react.ReactPackage;
|
|
9
|
+import com.facebook.react.ReactRootView;
|
9
|
10
|
import com.facebook.react.bridge.ReactContext;
|
10
|
11
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
11
|
12
|
import com.facebook.react.shell.MainReactPackage;
|
|
@@ -18,12 +19,13 @@ import java.util.Arrays;
|
18
|
19
|
import java.util.List;
|
19
|
20
|
|
20
|
21
|
public class NavigationActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler {
|
21
|
|
-
|
|
22
|
+ public static NavigationActivity instance;
|
22
|
23
|
private ReactNativeHost host;
|
23
|
24
|
|
24
|
25
|
@Override
|
25
|
26
|
public void onCreate(Bundle savedInstanceState) {
|
26
|
27
|
super.onCreate(savedInstanceState);
|
|
28
|
+ instance = this;
|
27
|
29
|
setContentView(R.layout.splash);
|
28
|
30
|
host = new ReactNativeHost(getApplication()) {
|
29
|
31
|
@Override
|
|
@@ -52,8 +54,6 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
|
52
|
54
|
}
|
53
|
55
|
});
|
54
|
56
|
host.getReactInstanceManager().createReactContextInBackground();
|
55
|
|
-
|
56
|
|
-
|
57
|
57
|
}
|
58
|
58
|
|
59
|
59
|
@Override
|
|
@@ -62,8 +62,27 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
|
62
|
62
|
host.getReactInstanceManager().onHostResume(this, this);
|
63
|
63
|
}
|
64
|
64
|
|
|
65
|
+ @Override
|
|
66
|
+ protected void onPause() {
|
|
67
|
+ super.onPause();
|
|
68
|
+ host.getReactInstanceManager().onHostPause(this);
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ @Override
|
|
72
|
+ protected void onDestroy() {
|
|
73
|
+ super.onDestroy();
|
|
74
|
+ instance = null;
|
|
75
|
+ host.getReactInstanceManager().onHostDestroy(this);
|
|
76
|
+ }
|
|
77
|
+
|
65
|
78
|
@Override
|
66
|
79
|
public void invokeDefaultOnBackPressed() {
|
67
|
80
|
onBackPressed();
|
68
|
81
|
}
|
|
82
|
+
|
|
83
|
+ public void setRoot(String name, Bundle args) {
|
|
84
|
+ ReactRootView v = new ReactRootView(getApplicationContext());
|
|
85
|
+ setContentView(v);
|
|
86
|
+ v.startReactApplication(host.getReactInstanceManager(), name, args);
|
|
87
|
+ }
|
69
|
88
|
}
|