[Android] Fix incorrect artist display on albums

Geoffrey Métais git at videolan.org
Thu Dec 21 14:05:49 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Dec 21 14:04:37 2017 +0100| [c142ffe8e962dce04423a3944e1b429028eaf1fd] | committer: Geoffrey Métais

Fix incorrect artist display on albums

'Various Artists' was displayed as 'Unknown Artist'

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

 .../src/org/videolan/medialibrary/media/Album.java    | 19 +++++++++----------
 .../src/org/videolan/medialibrary/media/Artist.java   | 14 ++++++--------
 2 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/media/Album.java b/medialibrary/src/org/videolan/medialibrary/media/Album.java
index a01731be8..f39698116 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/Album.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/Album.java
@@ -9,7 +9,10 @@ import org.videolan.medialibrary.Medialibrary;
 import org.videolan.medialibrary.R;
 
 public class Album extends MediaLibraryItem {
-    private static String UNKNOWN_ALBUM;
+    public static final String TAG = "VLC/Album";
+    static class SpecialRes {
+        static String UNKNOWN_ALBUM = Medialibrary.getContext().getString(R.string.unknown_album);
+    }
 
     private int releaseYear;
     private String artworkMrl;
@@ -26,15 +29,11 @@ public class Album extends MediaLibraryItem {
         this.albumArtistId = albumArtistId;
         this.mTracksCount = nbTracks;
         this.duration = duration;
-        if (TextUtils.isEmpty(title)) {
-            if (UNKNOWN_ALBUM == null)
-                UNKNOWN_ALBUM = Medialibrary.getContext().getString(R.string.unknown_album);
-            mTitle = UNKNOWN_ALBUM;
-        }
-        if (TextUtils.isEmpty(albumArtist)) {
-            if (Artist.UNKNOWN_ARTIST == null)
-                Artist.UNKNOWN_ARTIST = Medialibrary.getContext().getString(R.string.unknown_artist);
-            this.albumArtist = Artist.UNKNOWN_ARTIST;
+        if (TextUtils.isEmpty(title)) mTitle = SpecialRes.UNKNOWN_ALBUM;
+        if (albumArtistId == 1L) {
+            this.albumArtist = Artist.SpecialRes.UNKNOWN_ARTIST;
+        } else if (albumArtistId == 2L) {
+            this.albumArtist = Artist.SpecialRes.VARIOUS_ARTISTS;
         }
     }
 
diff --git a/medialibrary/src/org/videolan/medialibrary/media/Artist.java b/medialibrary/src/org/videolan/medialibrary/media/Artist.java
index 62c69efa4..e45d64012 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/Artist.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/Artist.java
@@ -13,8 +13,10 @@ public class Artist extends MediaLibraryItem {
     private String artworkMrl;
     private String musicBrainzId;
 
-    static String UNKNOWN_ARTIST;
-    private static String VARIOUS_ARTISTS;
+    static class SpecialRes {
+        static String UNKNOWN_ARTIST = Medialibrary.getContext().getString(R.string.unknown_artist);
+        static String VARIOUS_ARTISTS = Medialibrary.getContext().getString(R.string.various_artists);
+    }
 
     public Artist(long id, String name, String shortBio, String artworkMrl, String musicBrainzId) {
         super(id, name);
@@ -22,13 +24,9 @@ public class Artist extends MediaLibraryItem {
         this.artworkMrl = artworkMrl != null ? VLCUtil.UriFromMrl(artworkMrl).getPath() : null;
         this.musicBrainzId = musicBrainzId;
         if (id == 1L) {
-            if (UNKNOWN_ARTIST == null)
-                UNKNOWN_ARTIST = Medialibrary.getContext().getString(R.string.unknown_artist);
-            mTitle = UNKNOWN_ARTIST;
+            mTitle = SpecialRes.UNKNOWN_ARTIST;
         } else if (id == 2L) {
-            if (VARIOUS_ARTISTS == null)
-                VARIOUS_ARTISTS = Medialibrary.getContext().getString(R.string.various_artists);
-            mTitle = VARIOUS_ARTISTS;
+            mTitle = SpecialRes.VARIOUS_ARTISTS;
         }
     }
 



More information about the Android mailing list