|
|
|
|
14
|
import com.reactnativenavigation.react.NavigationEventEmitter;
|
14
|
import com.reactnativenavigation.react.NavigationEventEmitter;
|
15
|
import com.reactnativenavigation.react.NavigationPackage;
|
15
|
import com.reactnativenavigation.react.NavigationPackage;
|
16
|
import com.reactnativenavigation.react.ReactDevPermission;
|
16
|
import com.reactnativenavigation.react.ReactDevPermission;
|
|
|
17
|
+import com.reactnativenavigation.utils.UiThread;
|
17
|
|
18
|
|
18
|
import java.util.Arrays;
|
19
|
import java.util.Arrays;
|
19
|
import java.util.List;
|
20
|
import java.util.List;
|
20
|
import java.util.concurrent.atomic.AtomicBoolean;
|
21
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
22
|
+import java.util.concurrent.atomic.AtomicLong;
|
21
|
|
23
|
|
22
|
public abstract class NavigationApplication extends Application implements ReactApplication {
|
24
|
public abstract class NavigationApplication extends Application implements ReactApplication {
|
23
|
public static NavigationApplication instance;
|
25
|
public static NavigationApplication instance;
|
|
|
|
|
44
|
|
46
|
|
45
|
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
|
47
|
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
|
46
|
private AtomicBoolean creating = new AtomicBoolean(true);
|
48
|
private AtomicBoolean creating = new AtomicBoolean(true);
|
|
|
49
|
+ private AtomicLong startTime = new AtomicLong();
|
47
|
|
50
|
|
48
|
@Override
|
51
|
@Override
|
49
|
public void onActivityCreated(final Activity activity, Bundle bundle) {
|
52
|
public void onActivityCreated(final Activity activity, Bundle bundle) {
|
|
|
|
|
65
|
}
|
68
|
}
|
66
|
|
69
|
|
67
|
if (!host.getReactInstanceManager().hasStartedCreatingInitialContext()) {
|
70
|
if (!host.getReactInstanceManager().hasStartedCreatingInitialContext()) {
|
|
|
71
|
+ startTime.set(System.currentTimeMillis());
|
68
|
host.getReactInstanceManager().addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
|
72
|
host.getReactInstanceManager().addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
|
69
|
@Override
|
73
|
@Override
|
70
|
- public void onReactContextInitialized(ReactContext context) {
|
|
|
|
|
74
|
+ public void onReactContextInitialized(final ReactContext context) {
|
71
|
host.getReactInstanceManager().removeReactInstanceEventListener(this);
|
75
|
host.getReactInstanceManager().removeReactInstanceEventListener(this);
|
72
|
- new NavigationEventEmitter(context).emitAppLaunched();
|
|
|
|
|
76
|
+
|
|
|
77
|
+ long millisPassed = System.currentTimeMillis() - startTime.get();
|
|
|
78
|
+ long diff = 1000 - millisPassed;
|
|
|
79
|
+
|
|
|
80
|
+ UiThread.postDelayed(new Runnable() {
|
|
|
81
|
+ @Override
|
|
|
82
|
+ public void run() {
|
|
|
83
|
+ new NavigationEventEmitter(context).emitAppLaunched();
|
|
|
84
|
+ }
|
|
|
85
|
+ }, diff);
|
73
|
}
|
86
|
}
|
74
|
});
|
87
|
});
|
75
|
host.getReactInstanceManager().createReactContextInBackground();
|
88
|
host.getReactInstanceManager().createReactContextInBackground();
|
|
|
|
|
80
|
host.getReactInstanceManager().onHostResume(activity, (DefaultHardwareBackBtnHandler) activity);
|
93
|
host.getReactInstanceManager().onHostResume(activity, (DefaultHardwareBackBtnHandler) activity);
|
81
|
|
94
|
|
82
|
if (creating.compareAndSet(true, false)) {
|
95
|
if (creating.compareAndSet(true, false)) {
|
83
|
- new NavigationEventEmitter(host.getReactInstanceManager().getCurrentReactContext()).emitAppLaunched();
|
|
|
|
|
96
|
+ UiThread.postDelayed(new Runnable() {
|
|
|
97
|
+ @Override
|
|
|
98
|
+ public void run() {
|
|
|
99
|
+ new NavigationEventEmitter(host.getReactInstanceManager().getCurrentReactContext()).emitAppLaunched();
|
|
|
100
|
+ }
|
|
|
101
|
+ }, 1000);
|
84
|
}
|
102
|
}
|
85
|
}
|
103
|
}
|
86
|
|
104
|
|