Skip to content

Commit a428d71

Browse files
robbieDaniel Jung
authored andcommitted
[NO-ISSUE] navigation-v1 emiiter event null check for android creash (#9)
1 parent d517dfc commit a428d71

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

android/app/src/main/java/com/reactnativenavigation/bridge/EventEmitter.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,41 +57,59 @@ public void sendNavigatorEvent(String eventId, String navigatorEventId) {
5757
if (!NavigationApplication.instance.isReactContextInitialized()) {
5858
return;
5959
}
60-
reactGateway.getReactEventEmitter().sendNavigatorEvent(eventId, navigatorEventId);
60+
NavigationReactEventEmitter emitter = reactGateway.getReactEventEmitter();
61+
if (emitter != null) {
62+
emitter.sendNavigatorEvent(eventId, navigatorEventId);
63+
}
6164
}
6265

6366
public void sendNavigatorEvent(String eventId, String navigatorEventId, WritableMap data) {
6467
if (!NavigationApplication.instance.isReactContextInitialized()) {
6568
return;
6669
}
67-
reactGateway.getReactEventEmitter().sendNavigatorEvent(eventId, navigatorEventId, data);
70+
NavigationReactEventEmitter emitter = reactGateway.getReactEventEmitter();
71+
if (emitter != null) {
72+
emitter.sendNavigatorEvent(eventId, navigatorEventId, data);
73+
}
6874
}
6975

7076
public void sendEvent(String eventId, String navigatorEventId) {
7177
if (!NavigationApplication.instance.isReactContextInitialized()) {
7278
return;
7379
}
74-
reactGateway.getReactEventEmitter().sendEvent(eventId, navigatorEventId);
80+
NavigationReactEventEmitter emitter = reactGateway.getReactEventEmitter();
81+
if (emitter != null) {
82+
emitter.sendEvent(eventId, navigatorEventId);
83+
}
7584
}
7685

7786
public void sendNavigatorEvent(String eventId, WritableMap arguments) {
7887
if (!NavigationApplication.instance.isReactContextInitialized()) {
7988
return;
8089
}
81-
reactGateway.getReactEventEmitter().sendEvent(eventId, arguments);
90+
NavigationReactEventEmitter emitter = reactGateway.getReactEventEmitter();
91+
if (emitter != null) {
92+
emitter.sendEvent(eventId, arguments);
93+
}
8294
}
8395

8496
public void sendEvent(String eventId) {
8597
if (!NavigationApplication.instance.isReactContextInitialized()) {
8698
return;
8799
}
88-
reactGateway.getReactEventEmitter().sendEvent(eventId, Arguments.createMap());
100+
NavigationReactEventEmitter emitter = reactGateway.getReactEventEmitter();
101+
if (emitter != null) {
102+
emitter.sendEvent(eventId, Arguments.createMap());
103+
}
89104
}
90105

91106
public void sendAppLaunchedEvent() {
92107
if (!NavigationApplication.instance.isReactContextInitialized()) {
93108
return;
94109
}
95-
reactGateway.getReactEventEmitter().sendEvent("RNN.appLaunched", Arguments.createMap());
110+
NavigationReactEventEmitter emitter = reactGateway.getReactEventEmitter();
111+
if (emitter != null) {
112+
emitter.sendEvent("RNN.appLaunched", Arguments.createMap());
113+
}
96114
}
97115
}

0 commit comments

Comments
 (0)