如何修复此错误:
它告诉我错误来自第一行:
//Putting album art in album placeholder
**Error Here-->**if (album_list_of.get(position).getAlbumCover().contains("content://media/external/audio/albumart")) {
Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
Uri albumArtUri = ContentUris.withAppendedId(sArtworkUri, Integer.parseInt(album_list_of.get(position).getAlbumPosition()));
Glide.with(this)
.load(albumArtUri)
.error(R.drawable.no_song_image)
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.into(album_Cover);
} else {
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeFile(album_list_of.get(position).getAlbumCover(), bmOptions);
if (bitmap != null) {
Glide.with(this)
.load(bitmap)
.error(R.drawable.no_song_image)
.into(album_Cover);
}
}
1条答案
按热度按时间2ic8powd1#
album_list_of.get(position).getAlbumCover()
返回null。为其值添加null检查