[Android] PopupManager: Prevent NPE

Geoffrey Métais git at videolan.org
Fri Mar 1 15:05:52 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar  1 14:36:02 2019 +0100| [138fe2bbecfe8ed8b5d549b51bfb8ae135edc6ea] | committer: Geoffrey Métais

PopupManager: Prevent NPE

> https://code.videolan.org/videolan/vlc-android/commit/138fe2bbecfe8ed8b5d549b51bfb8ae135edc6ea
---

 .../src/org/videolan/vlc/gui/video/PopupManager.java  | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
index 8ec1117b8..6bc92aa58 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
@@ -30,8 +30,6 @@ import android.content.Intent;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
-import androidx.core.app.NotificationCompat;
-import androidx.core.view.GestureDetectorCompat;
 import android.util.Log;
 import android.view.GestureDetector;
 import android.view.LayoutInflater;
@@ -51,6 +49,9 @@ import org.videolan.vlc.gui.view.PopupLayout;
 import org.videolan.vlc.util.Constants;
 import org.videolan.vlc.util.Settings;
 
+import androidx.core.app.NotificationCompat;
+import androidx.core.view.GestureDetectorCompat;
+
 public class PopupManager implements PlaybackService.Callback, GestureDetector.OnDoubleTapListener,
         View.OnClickListener, GestureDetector.OnGestureListener, IVLCVout.OnNewVideoLayoutListener, IVLCVout.Callback {
 
@@ -208,15 +209,17 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
     public void onMediaPlayerEvent(MediaPlayer.Event event) {
         switch (event.type) {
             case MediaPlayer.Event.Playing:
-                if (!mAlwaysOn)
-                    mRootView.setKeepScreenOn(true);
-                mPlayPauseButton.setImageResource(R.drawable.ic_popup_pause);
+                if (mRootView != null) {
+                    if (!mAlwaysOn) mRootView.setKeepScreenOn(true);
+                    mPlayPauseButton.setImageResource(R.drawable.ic_popup_pause);
+                }
                 showNotification();
                 break;
             case MediaPlayer.Event.Paused:
-                if (!mAlwaysOn)
-                    mRootView.setKeepScreenOn(false);
-                mPlayPauseButton.setImageResource(R.drawable.ic_popup_play);
+                if (mRootView != null) {
+                    if (!mAlwaysOn) mRootView.setKeepScreenOn(false);
+                    mPlayPauseButton.setImageResource(R.drawable.ic_popup_play);
+                }
                 showNotification();
                 break;
         }



More information about the Android mailing list