[Android] Thread playlist saving in DB

Geoffrey Métais git at videolan.org
Tue May 19 16:58:17 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue May 19 16:40:12 2015 +0200| [e84b8ed1748036e8770ed15e0e0638612cb27626] | committer: Geoffrey Métais

Thread playlist saving in DB

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

 .../org/videolan/vlc/gui/dialogs/SavePlaylist.java |   24 ++++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylist.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylist.java
index 4a767c0..7c3a5bf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylist.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylist.java
@@ -114,16 +114,20 @@ public class SavePlaylist extends DialogFragment implements AdapterView.OnItemCl
     }
 
     private void savePlaylist() {
-        final MediaDatabase db = MediaDatabase.getInstance();
-        final String name = mEditText.getText().toString().trim();
-        if (db.playlistExists(name))
-            db.playlistDelete(name);
-        db.playlistAdd(name);
-        MediaWrapper mw;
-        for (int i = 0 ; i< mTracks.size() ; ++i){
-            mw = mTracks.get(i);
-            db.playlistInsertItem(name, i, mw.getLocation());
-        }
+        new Thread(new Runnable() {
+            public void run() {
+                final MediaDatabase db = MediaDatabase.getInstance();
+                final String name = mEditText.getText().toString().trim();
+                if (db.playlistExists(name))
+                    db.playlistDelete(name);
+                db.playlistAdd(name);
+                MediaWrapper mw;
+                for (int i = 0 ; i< mTracks.size() ; ++i){
+                    mw = mTracks.get(i);
+                    db.playlistInsertItem(name, i, mw.getLocation());
+                }
+            }
+        }).start();
         dismiss();
     }
 }



More information about the Android mailing list