check for null cursor

This commit is contained in:
Adrian Ulrich 2014-06-29 19:16:07 +02:00
parent 87f7838d68
commit e7f2be06ad

@ -175,19 +175,21 @@ public class Song implements Comparable<Song> {
String[] projection = new String [] { MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ALBUM }; String[] projection = new String [] { MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ALBUM };
QueryTask query = MediaUtils.buildQuery(MediaUtils.TYPE_SONG, key.id, projection, null); QueryTask query = MediaUtils.buildQuery(MediaUtils.TYPE_SONG, key.id, projection, null);
Cursor cursor = query.runQuery(mContext.getContentResolver()); Cursor cursor = query.runQuery(mContext.getContentResolver());
if (cursor.getCount() > 0) { if (cursor != null) {
cursor.moveToNext(); if (cursor.getCount() > 0) {
String thisArtist = cursor.getString(0); cursor.moveToNext();
String thisAlbum = cursor.getString(1); String thisArtist = cursor.getString(0);
String shadowPath = "/sdcard/Music/.vanilla/"+(thisArtist.replaceAll("/", "_"))+"/"+(thisAlbum.replaceAll("/", "_"))+".jpg"; String thisAlbum = cursor.getString(1);
String shadowPath = "/sdcard/Music/.vanilla/"+(thisArtist.replaceAll("/", "_"))+"/"+(thisAlbum.replaceAll("/", "_"))+".jpg";
File guessedFile = new File(shadowPath); File guessedFile = new File(shadowPath);
if (guessedFile.exists() && !guessedFile.isDirectory()) { if (guessedFile.exists() && !guessedFile.isDirectory()) {
inputStream = new FileInputStream(guessedFile); inputStream = new FileInputStream(guessedFile);
sampleInputStream = new FileInputStream(guessedFile); sampleInputStream = new FileInputStream(guessedFile);
}
} }
cursor.close();
} }
cursor.close();
} }
if (inputStream == null && (mCoverLoadMode & COVER_MODE_ANDROID) != 0) { if (inputStream == null && (mCoverLoadMode & COVER_MODE_ANDROID) != 0) {