Commit e84b8ed1 authored by Geoffrey Métais's avatar Geoffrey Métais

Thread playlist saving in DB

parent 455a98c5
...@@ -114,16 +114,20 @@ public class SavePlaylist extends DialogFragment implements AdapterView.OnItemCl ...@@ -114,16 +114,20 @@ public class SavePlaylist extends DialogFragment implements AdapterView.OnItemCl
} }
private void savePlaylist() { private void savePlaylist() {
final MediaDatabase db = MediaDatabase.getInstance(); new Thread(new Runnable() {
final String name = mEditText.getText().toString().trim(); public void run() {
if (db.playlistExists(name)) final MediaDatabase db = MediaDatabase.getInstance();
db.playlistDelete(name); final String name = mEditText.getText().toString().trim();
db.playlistAdd(name); if (db.playlistExists(name))
MediaWrapper mw; db.playlistDelete(name);
for (int i = 0 ; i< mTracks.size() ; ++i){ db.playlistAdd(name);
mw = mTracks.get(i); MediaWrapper mw;
db.playlistInsertItem(name, i, mw.getLocation()); for (int i = 0 ; i< mTracks.size() ; ++i){
} mw = mTracks.get(i);
db.playlistInsertItem(name, i, mw.getLocation());
}
}
}).start();
dismiss(); dismiss();
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment