[Android] Prevent NPE on media deletion

Geoffrey Métais git at videolan.org
Thu Oct 12 11:12:58 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Oct 12 10:59:25 2017 +0200| [4a66ec282ccb15a7024655ccd8dd8bd5b1a5a533] | committer: Geoffrey Métais

Prevent NPE on media deletion

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

 .../src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java     | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
index 31e078585..e19ff102b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
@@ -189,11 +189,12 @@ public abstract class MediaBrowserFragment extends PlaybackServiceFragment imple
                 for (String folder : foldersToReload)
                         mMediaLibrary.reload(folder);
                 if (mService != null && getActivity() != null) {
-                    getActivity().runOnUiThread(new Runnable() {
+                    VLCApplication.runOnMainThread(new Runnable() {
                         @Override
                         public void run() {
-                            for (String path : mediaPaths)
-                                mService.removeLocation(path);
+                            if (mService != null)
+                                for (String path : mediaPaths)
+                                    mService.removeLocation(path);
                             if (refresh)
                                 onRefresh();
                         }



More information about the Android mailing list