Fixed crash if music file has not artist metadata.
This commit is contained in:
parent
0155c3ac67
commit
8d48f73e07
2 changed files with 8 additions and 6 deletions
|
@ -133,7 +133,8 @@ 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);
|
||||||
artist = track.getArtists()[0].getName();
|
if (track.getArtists().length > 0)
|
||||||
|
artist = track.getArtists()[0].getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Intent intent = new Intent(MediaRouterPlayService.this, MainActivity.class);
|
Intent intent = new Intent(MediaRouterPlayService.this, MainActivity.class);
|
||||||
|
|
|
@ -88,7 +88,8 @@ 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());
|
||||||
artist.setText(track.getArtists()[0].getName());
|
if (track.getArtists().length > 0)
|
||||||
|
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;
|
||||||
|
|
Reference in a new issue