[Android] Prevent some NPE

Geoffrey Métais git at videolan.org
Thu Jul 7 17:26:23 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jul  7 17:26:00 2016 +0200| [cb921bb76607379aebac76d2a6cb6e0ea34a0063] | committer: Geoffrey Métais

Prevent some NPE

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

 .../src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java     | 2 +-
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java       | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
index 64313ba..f0d8690 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
@@ -169,7 +169,7 @@ public class PlaybackSpeedDialog extends DialogFragment implements PlaybackServi
         else
             initialRate = Math.ceil((initialRate - 0.005d) / 0.05d) * 0.05d;
         float rate = Math.round((initialRate + delta) * 100f) / 100f;
-        if (rate < 0.25f || rate > 4f)
+        if (rate < 0.25f || rate > 4f || mService.getCurrentMediaWrapper() == null)
             return;
         mService.setRate(rate, mService.getCurrentMediaWrapper().getType() == MediaWrapper.TYPE_AUDIO);
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 60d5616..9956050 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -563,7 +563,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     @Override
     protected void onNewIntent(Intent intent) {
         setIntent(intent);
-        if (mPlaybackStarted) {
+        if (mPlaybackStarted && mService.getCurrentMediaWrapper() != null) {
             Uri uri = intent.hasExtra(PLAY_EXTRA_ITEM_LOCATION) ?
                     (Uri) intent.getExtras().getParcelable(PLAY_EXTRA_ITEM_LOCATION) : intent.getData();
             if (uri == null || uri.equals(mUri))
@@ -1319,8 +1319,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
     private void initPlaybackSettingInfo() {
         if (mPresentation == null) {
-            mVerticalBar.setVisibility(View.GONE);
-            mOverlayInfo.setVisibility(View.VISIBLE);
+            UiTools.setViewVisibility(mVerticalBar, View.GONE);
+            UiTools.setViewVisibility(mOverlayInfo, View.VISIBLE)
         } else
             mInfo.setVisibility(View.VISIBLE);
         String text = "";
@@ -1445,6 +1445,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
      */
     private void showInfoWithVerticalBar(String text, int duration, int barNewValue) {
         showInfo(text, duration);
+        if (mVerticalBarProgress == null)
+            return;
         LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mVerticalBarProgress.getLayoutParams();
         layoutParams.weight = barNewValue;
         mVerticalBarProgress.setLayoutParams(layoutParams);



More information about the Android mailing list