Commit 71c54fe2 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Prevent NPE in notification generation

parent 7ec8d67e
......@@ -164,10 +164,12 @@ public class Util {
@NonNull
public static String getMediaDescription(String artist, String album) {
StringBuilder contentBuilder = new StringBuilder(artist);
if (contentBuilder.length() > 0 && !TextUtils.isEmpty(album))
contentBuilder.append(" - ");
contentBuilder.append(album);
boolean hasArtist = !TextUtils.isEmpty(artist);
boolean hasAlbum = !TextUtils.isEmpty(album);
if (!hasAlbum && !hasArtist) return "";
StringBuilder contentBuilder = new StringBuilder(hasArtist ? artist : "");
if (hasArtist && hasAlbum) contentBuilder.append(" - ");
if (hasAlbum) contentBuilder.append(album);
return contentBuilder.toString();
}
......
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