|
@@ -3,12 +3,56 @@ package com.reactnativenavigation.controllers;
|
3
|
3
|
import android.os.Bundle;
|
4
|
4
|
import android.support.v7.app.AppCompatActivity;
|
5
|
5
|
|
|
6
|
+import com.facebook.react.ReactNativeHost;
|
|
7
|
+import com.facebook.react.ReactPackage;
|
|
8
|
+import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
|
9
|
+import com.facebook.react.shell.MainReactPackage;
|
6
|
10
|
import com.reactnativenavigation.R;
|
|
11
|
+import com.reactnativenavigation.react.NavigationPackage;
|
|
12
|
+import com.reactnativenavigation.react.ReactDevPermission;
|
|
13
|
+
|
|
14
|
+import java.util.Arrays;
|
|
15
|
+import java.util.List;
|
|
16
|
+
|
|
17
|
+public class NavigationActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler {
|
|
18
|
+
|
|
19
|
+ private ReactNativeHost host;
|
7
|
20
|
|
8
|
|
-public class NavigationActivity extends AppCompatActivity {
|
9
|
21
|
@Override
|
10
|
22
|
public void onCreate(Bundle savedInstanceState) {
|
11
|
23
|
super.onCreate(savedInstanceState);
|
12
|
24
|
setContentView(R.layout.splash);
|
|
25
|
+ host = new ReactNativeHost(getApplication()) {
|
|
26
|
+ @Override
|
|
27
|
+ protected boolean getUseDeveloperSupport() {
|
|
28
|
+ return NavigationApplication.instance.isDebug();
|
|
29
|
+ }
|
|
30
|
+
|
|
31
|
+ @Override
|
|
32
|
+ protected List<ReactPackage> getPackages() {
|
|
33
|
+ return Arrays.asList(
|
|
34
|
+ new MainReactPackage(),
|
|
35
|
+ new NavigationPackage()
|
|
36
|
+ );
|
|
37
|
+ }
|
|
38
|
+ };
|
|
39
|
+
|
|
40
|
+ if (ReactDevPermission.shouldAskPermission()) {
|
|
41
|
+ ReactDevPermission.askPermission(this);
|
|
42
|
+ return;
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ host.getReactInstanceManager().createReactContextInBackground();
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ @Override
|
|
49
|
+ protected void onResume() {
|
|
50
|
+ super.onResume();
|
|
51
|
+ host.getReactInstanceManager().onHostResume(this, this);
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ @Override
|
|
55
|
+ public void invokeDefaultOnBackPressed() {
|
|
56
|
+ onBackPressed();
|
13
|
57
|
}
|
14
|
58
|
}
|