[Android] Atomic update for dbManager values

Geoffrey Métais git at videolan.org
Wed Feb 18 11:13:04 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 18 11:04:48 2015 +0100| [09e9f09737573878cf1efb2699d9fd75d31b194e] | committer: Geoffrey Métais

Atomic update for dbManager values

CID #1226286

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

 vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
index 94e997c..a9ec846 100644
--- a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
@@ -129,10 +129,12 @@ public class BrowserActivity extends ListActivity {
             public boolean onMenuItemClick(MenuItem arg0) {
                 // remove any checkmarks of the custom item
                 final MediaDatabase dbManager = MediaDatabase.getInstance();
-                for(File f : dbManager.getMediaDirs()) {
-                    final String path = f.getPath();
-                    if(path.startsWith(item.getPath()))
-                        dbManager.removeDir(path);
+                synchronized (dbManager) {
+                    for(File f : dbManager.getMediaDirs()) {
+                        final String path = f.getPath();
+                        if(path.startsWith(item.getPath()))
+                            dbManager.removeDir(path);
+                    }
                 }
                 CustomDirectories.removeCustomDirectory(item.getPath());
                 refresh();



More information about the Android mailing list