From 8d48f73e075729eb54f7aef8cad2c864a493a519 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 2 Jan 2014 17:25:20 +0100 Subject: [PATCH] Fixed crash if music file has not artist metadata. --- .../mediarouter/MediaRouterPlayService.java | 3 ++- .../nutomic/controldlna/utility/FileArrayAdapter.java | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java index 9719872..b518d88 100644 --- a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java +++ b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java @@ -133,7 +133,8 @@ public class MediaRouterPlayService extends Service { title = mPlaylist.get(mCurrentTrack).getTitle(); if (mPlaylist.get(mCurrentTrack) instanceof MusicTrack) { MusicTrack track = (MusicTrack) mPlaylist.get(mCurrentTrack); - artist = track.getArtists()[0].getName(); + if (track.getArtists().length > 0) + artist = track.getArtists()[0].getName(); } } Intent intent = new Intent(MediaRouterPlayService.this, MainActivity.class); diff --git a/src/com/github/nutomic/controldlna/utility/FileArrayAdapter.java b/src/com/github/nutomic/controldlna/utility/FileArrayAdapter.java index 08a8066..ecd93f8 100644 --- a/src/com/github/nutomic/controldlna/utility/FileArrayAdapter.java +++ b/src/com/github/nutomic/controldlna/utility/FileArrayAdapter.java @@ -88,7 +88,8 @@ public class FileArrayAdapter extends ArrayAdapter { } DIDLObject item = getItem(position); TextView title = (TextView) convertView.findViewById(R.id.title); - TextView artist = (TextView) convertView.findViewById(R.id.subtitle); + TextView artist = (TextView) convertView.findViewById(R.id.subtitle); + artist.setText(""); RemoteImageView image = (RemoteImageView) convertView.findViewById(R.id.image); if (item instanceof MusicTrack) { MusicTrack track = (MusicTrack) item; @@ -96,12 +97,12 @@ public class FileArrayAdapter extends ArrayAdapter { ? Integer.toString(track.getOriginalTrackNumber()) + ". " : ""; title.setText(trackNumber + item.getTitle()); - artist.setText(track.getArtists()[0].getName()); + if (track.getArtists().length > 0) + artist.setText(track.getArtists()[0].getName()); } - else { + else title.setText(item.getTitle()); - artist.setText(""); - } + image.setImageUri(item.getFirstPropertyValue( DIDLObject.Property.UPNP.ALBUM_ART_URI.class)); return convertView;