Fixed crash if music file has not artist metadata.

This commit is contained in:
Felix Ableitner 2014-01-02 17:25:20 +01:00
parent 0155c3ac67
commit 8d48f73e07
2 changed files with 8 additions and 6 deletions

View file

@ -133,6 +133,7 @@ public class MediaRouterPlayService extends Service {
title = mPlaylist.get(mCurrentTrack).getTitle(); title = mPlaylist.get(mCurrentTrack).getTitle();
if (mPlaylist.get(mCurrentTrack) instanceof MusicTrack) { if (mPlaylist.get(mCurrentTrack) instanceof MusicTrack) {
MusicTrack track = (MusicTrack) mPlaylist.get(mCurrentTrack); MusicTrack track = (MusicTrack) mPlaylist.get(mCurrentTrack);
if (track.getArtists().length > 0)
artist = track.getArtists()[0].getName(); artist = track.getArtists()[0].getName();
} }
} }

View file

@ -89,6 +89,7 @@ public class FileArrayAdapter extends ArrayAdapter<DIDLObject> {
DIDLObject item = getItem(position); DIDLObject item = getItem(position);
TextView title = (TextView) convertView.findViewById(R.id.title); 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); RemoteImageView image = (RemoteImageView) convertView.findViewById(R.id.image);
if (item instanceof MusicTrack) { if (item instanceof MusicTrack) {
MusicTrack track = (MusicTrack) item; MusicTrack track = (MusicTrack) item;
@ -96,12 +97,12 @@ public class FileArrayAdapter extends ArrayAdapter<DIDLObject> {
? Integer.toString(track.getOriginalTrackNumber()) + ". " ? Integer.toString(track.getOriginalTrackNumber()) + ". "
: ""; : "";
title.setText(trackNumber + item.getTitle()); title.setText(trackNumber + item.getTitle());
if (track.getArtists().length > 0)
artist.setText(track.getArtists()[0].getName()); artist.setText(track.getArtists()[0].getName());
} }
else { else
title.setText(item.getTitle()); title.setText(item.getTitle());
artist.setText("");
}
image.setImageUri(item.getFirstPropertyValue( image.setImageUri(item.getFirstPropertyValue(
DIDLObject.Property.UPNP.ALBUM_ART_URI.class)); DIDLObject.Property.UPNP.ALBUM_ART_URI.class));
return convertView; return convertView;