|
@@ -8,22 +8,18 @@ import com.facebook.react.ReactApplication;
|
8
|
8
|
import com.facebook.react.ReactNativeHost;
|
9
|
9
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
10
|
10
|
import com.reactnativenavigation.controllers.ActivityLifecycleDelegate;
|
|
11
|
+import com.reactnativenavigation.react.DevPermissionRequestImpl;
|
11
|
12
|
import com.reactnativenavigation.react.NavigationReactNativeHost;
|
12
|
13
|
|
13
|
14
|
public abstract class NavigationApplication extends Application implements ReactApplication {
|
14
|
15
|
public static NavigationApplication instance;
|
15
|
16
|
|
16
|
17
|
public static class Config {
|
17
|
|
- public final ReactNativeHost reactNativeHost;
|
18
|
|
- public final ActivityLifecycleDelegate activityLifecycleDelegate;
|
19
|
|
-
|
20
|
|
- public Config(ReactNativeHost reactNativeHost, ActivityLifecycleDelegate activityLifecycleDelegate) {
|
21
|
|
- this.reactNativeHost = reactNativeHost;
|
22
|
|
- this.activityLifecycleDelegate = activityLifecycleDelegate;
|
23
|
|
- }
|
|
18
|
+ public ReactNativeHost reactNativeHost;
|
|
19
|
+ public ActivityLifecycleDelegate activityLifecycleDelegate;
|
24
|
20
|
}
|
25
|
21
|
|
26
|
|
- public Config config;
|
|
22
|
+ private Config config;
|
27
|
23
|
|
28
|
24
|
@Override
|
29
|
25
|
public void onCreate() {
|
|
@@ -34,7 +30,7 @@ public abstract class NavigationApplication extends Application implements React
|
34
|
30
|
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
|
35
|
31
|
@Override
|
36
|
32
|
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
37
|
|
- config.activityLifecycleDelegate.onActivityCreated(activity);
|
|
33
|
+ getConfig().activityLifecycleDelegate.onActivityCreated(activity);
|
38
|
34
|
}
|
39
|
35
|
|
40
|
36
|
@Override
|
|
@@ -44,12 +40,12 @@ public abstract class NavigationApplication extends Application implements React
|
44
|
40
|
|
45
|
41
|
@Override
|
46
|
42
|
public void onActivityResumed(Activity activity) {
|
47
|
|
- config.activityLifecycleDelegate.onActivityResumed(activity, (DefaultHardwareBackBtnHandler) activity);
|
|
43
|
+ getConfig().activityLifecycleDelegate.onActivityResumed(activity, (DefaultHardwareBackBtnHandler) activity);
|
48
|
44
|
}
|
49
|
45
|
|
50
|
46
|
@Override
|
51
|
47
|
public void onActivityPaused(Activity activity) {
|
52
|
|
- config.activityLifecycleDelegate.onActivityPaused(activity);
|
|
48
|
+ getConfig().activityLifecycleDelegate.onActivityPaused(activity);
|
53
|
49
|
}
|
54
|
50
|
|
55
|
51
|
@Override
|
|
@@ -64,14 +60,18 @@ public abstract class NavigationApplication extends Application implements React
|
64
|
60
|
|
65
|
61
|
@Override
|
66
|
62
|
public void onActivityDestroyed(Activity activity) {
|
67
|
|
- config.activityLifecycleDelegate.onActivityDestroyed(activity);
|
|
63
|
+ getConfig().activityLifecycleDelegate.onActivityDestroyed(activity);
|
68
|
64
|
}
|
69
|
65
|
});
|
70
|
66
|
}
|
71
|
67
|
|
|
68
|
+ public final Config getConfig() {
|
|
69
|
+ return config;
|
|
70
|
+ }
|
|
71
|
+
|
72
|
72
|
@Override
|
73
|
73
|
public ReactNativeHost getReactNativeHost() {
|
74
|
|
- return config.reactNativeHost;
|
|
74
|
+ return getConfig().reactNativeHost;
|
75
|
75
|
}
|
76
|
76
|
|
77
|
77
|
public abstract boolean isDebug();
|
|
@@ -82,8 +82,9 @@ public abstract class NavigationApplication extends Application implements React
|
82
|
82
|
* @return the Config
|
83
|
83
|
*/
|
84
|
84
|
protected Config createConfig() {
|
85
|
|
- ReactNativeHost reactNativeHost = new NavigationReactNativeHost(this, isDebug());
|
86
|
|
- ActivityLifecycleDelegate activityLifecycleDelegate = new ActivityLifecycleDelegate(reactNativeHost.getReactInstanceManager());
|
87
|
|
- return new Config(reactNativeHost, activityLifecycleDelegate);
|
|
85
|
+ Config config = new Config();
|
|
86
|
+ config.reactNativeHost = new NavigationReactNativeHost(this, isDebug());
|
|
87
|
+ config.activityLifecycleDelegate = new ActivityLifecycleDelegate(config.reactNativeHost.getReactInstanceManager(), new DevPermissionRequestImpl());
|
|
88
|
+ return config;
|
88
|
89
|
}
|
89
|
90
|
}
|