[Android] Do not use a stored context for Util.getValue

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:41:51 2012 +0200| [bff5c24a46a54f3bc63b341af4b88d535525d9cc] | committer: Jean-Baptiste Kempf

Do not use a stored context for Util.getValue

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

 vlc-android/src/org/videolan/vlc/Media.java |   12 ++++++------
 vlc-android/src/org/videolan/vlc/Util.java  |    5 +++--
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/Media.java b/vlc-android/src/org/videolan/vlc/Media.java
index 8daaab8..4eb5e59 100644
--- a/vlc-android/src/org/videolan/vlc/Media.java
+++ b/vlc-android/src/org/videolan/vlc/Media.java
@@ -134,9 +134,9 @@ public class Media implements Comparable<Media> {
                 if (track.Type == TrackInfo.TYPE_META) {
                     mLength = track.Length;
                     mTitle = track.Title;
-                    mArtist = Util.getValue(context, track.Artist, R.string.unknown_artist);
-                    mAlbum = Util.getValue(context, track.Album, R.string.unknown_album);
-                    mGenre = Util.getValue(context, track.Genre, R.string.unknown_genre);
+                    mArtist = Util.getValue(track.Artist, R.string.unknown_artist);
+                    mAlbum = Util.getValue(track.Album, R.string.unknown_album);
+                    mGenre = Util.getValue(track.Genre, R.string.unknown_genre);
                     mArtworkURL = track.ArtworkURL;
                     Log.d(TAG, "Title " + mTitle);
                     Log.d(TAG, "Artist " + mArtist);
@@ -168,9 +168,9 @@ public class Media implements Comparable<Media> {
         mHeight = height;
 
         mTitle = title;
-        mArtist = Util.getValue(context, artist, R.string.unknown_artist);
-        mGenre = Util.getValue(context, genre, R.string.unknown_genre);
-        mAlbum = Util.getValue(context, album, R.string.unknown_album);
+        mArtist = Util.getValue(artist, R.string.unknown_artist);
+        mGenre = Util.getValue(genre, R.string.unknown_genre);
+        mAlbum = Util.getValue(album, R.string.unknown_album);
         mArtworkURL = artworkURL;
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/Util.java b/vlc-android/src/org/videolan/vlc/Util.java
index 4dbe893..9d7063b 100644
--- a/vlc-android/src/org/videolan/vlc/Util.java
+++ b/vlc-android/src/org/videolan/vlc/Util.java
@@ -158,9 +158,10 @@ public class Util {
                 (width - (2 * left)), (height - (2 * top)));
     }
 
-    public static String getValue(Context context, String string, int defaultId)
+    public static String getValue(String string, int defaultId)
     {
-        return (string != null && string.length() > 0) ? string : context.getString(defaultId);
+        return (string != null && string.length() > 0) ?
+                string : VLCApplication.getAppContext().getString(defaultId);
     }
 
     public static void setItemBackground(View v, int position) {



More information about the Android mailing list