[Android] Ensure playlist cleaning is done in main thread

Geoffrey Métais git at videolan.org
Thu Jan 7 15:05:57 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan  7 15:04:23 2016 +0100| [a504bba8030354c744dabc61491af875d1d9dd8f] | committer: Geoffrey Métais

Ensure playlist cleaning is done in main thread

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

 .../src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java | 9 +++++++--
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java     | 9 ++++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index a6f869b..7923d2f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -375,8 +375,13 @@ public class AudioAlbumsSongsFragment extends PlaybackServiceFragment implements
         for (final MediaWrapper media : listItem.mMediaList) {
             mMediaList.remove(media);
             mMediaLibrary.getMediaItems().remove(media);
-            if (mService != null)
-                mService.removeLocation(media.getLocation());
+            mHandler.post(new Runnable() {
+                @Override
+                public void run() {
+                    if (mService != null)
+                        mService.removeLocation(media.getLocation());
+                }
+            });
             VLCApplication.runBackground(new Runnable() {
                 @Override
                 public void run() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index ae6514b..365595f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -681,9 +681,16 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
             @Override
             public void run() {
                 final String path = mw.getUri().getPath();
-                boolean delete = FileUtils.deleteFile(path);
+                FileUtils.deleteFile(path);
                 MediaDatabase.getInstance().removeMedia(mw.getUri());
                 mMediaLibrary.getMediaItems().remove(mw);
+                mHandler.post(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (mService != null)
+                            mService.removeLocation(mw.getLocation());
+                    }
+                });
                 mHandler.obtainMessage(REFRESH, path).sendToTarget();
             }
         });



More information about the Android mailing list