[Android] Add saveSlave util method

Geoffrey Métais git at videolan.org
Tue May 31 18:27:05 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue May 31 18:13:00 2016 +0200| [ed01335b5536ce551f7786ba3c350ac203f1997a] | committer: Geoffrey Métais

Add saveSlave util method

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

 .../src/org/videolan/vlc/media/MediaDatabase.java     | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java
index 2b75e21..96c5f0e 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/media/MediaDatabase.java
@@ -1343,15 +1343,18 @@ public class MediaDatabase {
      * slaves management
      */
 
+    public synchronized void saveSlave(String mediaPath, int type, int priority, String uriString) {
+        ContentValues values = new ContentValues();
+        values.put(SLAVES_MEDIA_PATH, mediaPath);
+        values.put(SLAVES_TYPE, type);
+        values.put(SLAVES_PRIORITY, priority);
+        values.put(SLAVES_URI, uriString);
+        mDb.replace(SLAVES_TABLE_NAME, null, values);
+    }
+
     public synchronized void saveSlaves(MediaWrapper mw) {
-        for (Media.Slave slave : mw.getSlaves()) {
-            ContentValues values = new ContentValues();
-            values.put(SLAVES_MEDIA_PATH, mw.getLocation());
-            values.put(SLAVES_TYPE, slave.type);
-            values.put(SLAVES_PRIORITY, slave.priority);
-            values.put(SLAVES_URI, slave.uri);
-            mDb.replace(SLAVES_TABLE_NAME, null, values);
-        }
+        for (Media.Slave slave : mw.getSlaves())
+            saveSlave(mw.getLocation(), slave.type, slave.priority, slave.uri);
     }
 
     public synchronized ArrayList<Media.Slave> getSlaves(String mrl) {



More information about the Android mailing list