Prevent NPEs

This commit is contained in:
Martin Fietz 2017-05-01 17:56:08 +02:00
parent 293fb131e6
commit 932748ef70
1 changed files with 9 additions and 5 deletions

View File

@ -368,14 +368,18 @@ public class PlaybackService extends MediaBrowserServiceCompat {
} }
private MediaBrowserCompat.MediaItem createBrowsableMediaItemForFeed(Feed feed) { private MediaBrowserCompat.MediaItem createBrowsableMediaItemForFeed(Feed feed) {
MediaDescriptionCompat description = new MediaDescriptionCompat.Builder() MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder()
.setMediaId("FeedId:" + Long.toString(feed.getId())) .setMediaId("FeedId:" + Long.toString(feed.getId()))
.setTitle(feed.getTitle()) .setTitle(feed.getTitle())
.setDescription(feed.getDescription()) .setDescription(feed.getDescription())
.setIconUri(Uri.parse(feed.getImageLocation())) .setSubtitle(feed.getCustomTitle());
.setSubtitle(feed.getCustomTitle()) if(feed.getImageLocation() != null) {
.setMediaUri(Uri.parse(feed.getLink())) builder.setIconUri(Uri.parse(feed.getImageLocation()));
.build(); }
if(feed.getLink() != null) {
builder.setMediaUri(Uri.parse(feed.getLink()));
}
MediaDescriptionCompat description = builder.build();
return new MediaBrowserCompat.MediaItem(description, return new MediaBrowserCompat.MediaItem(description,
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE); MediaBrowserCompat.MediaItem.FLAG_BROWSABLE);
} }