[Android] Prevent NPE in video player

Geoffrey Métais git at videolan.org
Mon Nov 16 17:58:37 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Nov 16 17:57:44 2015 +0100| [a943d852a4d8cd450fbaba8dffba1842e100b286] | committer: Geoffrey Métais

Prevent NPE in video player

Seekbar can sometimes send back events while activity is getting
finished.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=a943d852a4d8cd450fbaba8dffba1842e100b286
---

 .../vlc/gui/video/VideoPlayerActivity.java         |   21 ++++----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

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 2d565f5..9337a51 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1312,19 +1312,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     }
 
     /**
-     * Show text in the info view
-     * @param text
-     */
-    private void showInfo(String text) {
-        if (mPresentation == null)
-            mVerticalBar.setVisibility(View.GONE);
-        mHandler.removeMessages(FADE_OUT_INFO);
-        mInfo.setVisibility(View.VISIBLE);
-        mInfo.setText(text);
-        hideInfo();
-    }
-
-    /**
      * hide the info view with "delay" milliseconds delay
      * @param delay
      */
@@ -1990,11 +1977,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
         @Override
         public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-            if (fromUser && mService.isSeekable()) {
+            if (!isFinishing() && fromUser && mService.isSeekable()) {
                 seek(progress);
                 setOverlayProgress();
                 mTime.setText(Strings.millisToString(progress));
-                showInfo(Strings.millisToString(progress));
+                showInfo(Strings.millisToString(progress), 1000);
             }
         }
     };
@@ -2133,11 +2120,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             if (mService == null)
                 return false;
             if (mService.getRepeatType() == PlaybackService.REPEAT_ONE) {
-                showInfo(getString(R.string.repeat));
+                showInfo(getString(R.string.repeat), 1000);
                 mService.setRepeatType(PlaybackService.REPEAT_NONE);
             } else {
                 mService.setRepeatType(PlaybackService.REPEAT_ONE);
-                showInfo(getString(R.string.repeat_single));
+                showInfo(getString(R.string.repeat_single), 1000);
             }
             return true;
         }



More information about the Android mailing list