Pārlūkot izejas kodu

Fixes NPE when initializing twice (#3128)

andresesfm 6 gadus atpakaļ
vecāks
revīzija
0bf0751f5d

+ 6
- 6
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationReactInitializer.java Parādīt failu

@@ -45,14 +45,14 @@ public class NavigationReactInitializer implements ReactInstanceManager.ReactIns
45 45
 	private void prepareReactApp() {
46 46
 		if (shouldCreateContext()) {
47 47
 			reactInstanceManager.createReactContextInBackground();
48
-		} else if (waitingForAppLaunchEvent) {
49
-			emitAppLaunched();
50 48
 		}
51 49
 	}
52 50
 
53
-	private void emitAppLaunched() {
54
-		waitingForAppLaunchEvent = false;
55
-		new NavigationEvent(reactInstanceManager.getCurrentReactContext()).appLaunched();
51
+	private void emitAppLaunched(final ReactContext context) {
52
+		if (waitingForAppLaunchEvent) {
53
+			waitingForAppLaunchEvent = false;
54
+			new NavigationEvent(context).appLaunched();
55
+		}
56 56
 	}
57 57
 
58 58
 	private boolean shouldCreateContext() {
@@ -61,6 +61,6 @@ public class NavigationReactInitializer implements ReactInstanceManager.ReactIns
61 61
 
62 62
 	@Override
63 63
 	public void onReactContextInitialized(final ReactContext context) {
64
-		emitAppLaunched();
64
+		emitAppLaunched(context);
65 65
 	}
66 66
 }