Skip to content

Commit 678afad

Browse files
authored
fix(android): missing listener instance try catch (#110)
1 parent 2a7d334 commit 678afad

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

android/src/main/java/com/orientationdirector/OrientationDirectorModule.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,27 @@ class OrientationDirectorModule(reactContext: ReactApplicationContext) :
5050
}
5151

5252
override fun sendOnDeviceOrientationChanged(params: WritableMap) {
53-
emitOnDeviceOrientationChanged(params)
53+
try {
54+
emitOnDeviceOrientationChanged(params)
55+
} catch(_: Exception) {
56+
// No listener instance yet
57+
}
5458
}
5559

5660
override fun sendOnInterfaceOrientationChanged(params: WritableMap) {
57-
emitOnInterfaceOrientationChanged(params)
61+
try {
62+
emitOnInterfaceOrientationChanged(params)
63+
} catch(_: Exception) {
64+
// No listener instance yet
65+
}
5866
}
5967

6068
override fun sendOnLockChanged(params: WritableMap) {
61-
emitOnLockChanged(params)
69+
try {
70+
emitOnLockChanged(params)
71+
} catch(_: Exception) {
72+
// No listener instance yet
73+
}
6274
}
6375

6476
companion object {

0 commit comments

Comments
 (0)