From 4fecdac9dff1a89233f69694a771ba5e7d022f65 Mon Sep 17 00:00:00 2001 From: Pablo Soares Date: Tue, 13 Jun 2017 18:05:13 -0300 Subject: [PATCH 1/2] Prevent NPE on onHostResume This call to helper.onResume() was causing intermitent NPE's They happened during app initialization but I could not identify the reason; usually after a reload --- .../com/mybigday/rnmediaplayer/ExternalDisplay.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/mybigday/rnmediaplayer/ExternalDisplay.java b/android/src/main/java/com/mybigday/rnmediaplayer/ExternalDisplay.java index 9a9a226..525d9dc 100644 --- a/android/src/main/java/com/mybigday/rnmediaplayer/ExternalDisplay.java +++ b/android/src/main/java/com/mybigday/rnmediaplayer/ExternalDisplay.java @@ -142,7 +142,7 @@ public void start() { if (alreadyStarted) return; initLayoutView(); tryShowPreview(); - + root = new Root(context, reactContext, containerView); alreadyStarted = true; } @@ -244,14 +244,20 @@ public void clearScreen() { @Override public void onHostResume() { start(); - helper.onResume(); + // Don't know why this would be null at this point + if (helper != null) { + helper.onResume(); + } showVirtualScreen(true); } @Override public void onHostPause() { showVirtualScreen(false); - helper.onPause(); + // Don't know why this would be null at this point + if (helper != null) { + helper.onResume(); + } tryRemovePreview(); } From 074a8636de5ce4df3a4c4c7d0791e023ac1e5c64 Mon Sep 17 00:00:00 2001 From: Pablo Soares Date: Thu, 22 Jun 2017 12:31:11 -0300 Subject: [PATCH 2/2] Remove null check on onHostPause as it is unecessary --- .../java/com/mybigday/rnmediaplayer/ExternalDisplay.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/android/src/main/java/com/mybigday/rnmediaplayer/ExternalDisplay.java b/android/src/main/java/com/mybigday/rnmediaplayer/ExternalDisplay.java index 525d9dc..01a447c 100644 --- a/android/src/main/java/com/mybigday/rnmediaplayer/ExternalDisplay.java +++ b/android/src/main/java/com/mybigday/rnmediaplayer/ExternalDisplay.java @@ -254,10 +254,7 @@ public void onHostResume() { @Override public void onHostPause() { showVirtualScreen(false); - // Don't know why this would be null at this point - if (helper != null) { - helper.onResume(); - } + helper.onResume(); tryRemovePreview(); }