[Android] Do not use a stored Context in Media

Jean-Baptiste Kempf git at videolan.org
Mon Jun 25 12:59:00 CEST 2012


android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Jun 25 12:45:18 2012 +0200| [788425a3cd206f05d069a59a91de0da377c1409f] | committer: Jean-Baptiste Kempf

Do not use a stored Context in Media

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=788425a3cd206f05d069a59a91de0da377c1409f
---

 vlc-android/src/org/videolan/vlc/AudioService.java         |    2 +-
 vlc-android/src/org/videolan/vlc/Media.java                |    4 ++--
 vlc-android/src/org/videolan/vlc/MediaLibrary.java         |    2 +-
 vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index 8cb0eb6..bc12d1f 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -565,7 +565,7 @@ public class AudioService extends Service {
                 Media media = db.getMedia(AudioService.this, path);
                 if(media == null) {
                     Log.v(TAG, "Creating on-the-fly Media object for " + path);
-                    media = new Media(AudioService.this, path, false);
+                    media = new Media(path, false);
                 }
                 mMediaList.add(media);
             }
diff --git a/vlc-android/src/org/videolan/vlc/Media.java b/vlc-android/src/org/videolan/vlc/Media.java
index 4eb5e59..4cc7a55 100644
--- a/vlc-android/src/org/videolan/vlc/Media.java
+++ b/vlc-android/src/org/videolan/vlc/Media.java
@@ -114,7 +114,7 @@ public class Media implements Comparable<Media> {
      * @param media URI
      * @param addToDb Should it be added to the file database?
      */
-    public Media(Context context, String URI, Boolean addToDb) {
+    public Media(String URI, Boolean addToDb) {
         mLocation = URI;
 
         LibVLC mLibVlc = null;
@@ -150,7 +150,7 @@ public class Media implements Comparable<Media> {
 
         if (addToDb) {
             // Add this item to database
-            DatabaseManager db = DatabaseManager.getInstance(context);
+            DatabaseManager db = DatabaseManager.getInstance(VLCApplication.getAppContext());
             db.addMedia(this);
         }
     }
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index 6f2ae3e..9a5e099 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -235,7 +235,7 @@ public class MediaLibrary {
                                 }
                             } else {
                                 // create new media item
-                                mItemList.add(new Media(mContext, fileURI, true));
+                                mItemList.add(new Media(fileURI, true));
                             }
                         } else if (file.isDirectory()) {
                             directories.push(file);
diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
index b34cd3a..e876448 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
@@ -250,7 +250,7 @@ public class DirectoryAdapter extends BaseAdapter {
         String holderText = "";
         if(selectedNode.isFile()) {
             Log.d(TAG, "Loading media " + selectedNode.name);
-            Media m = new Media(mContext, getMediaLocation(position), false);
+            Media m = new Media(getMediaLocation(position), false);
             holder.title.setText(m.getTitle());
             holderText = m.getArtist() + " - " + m.getAlbum();
         } else



More information about the Android mailing list