Add a check for an empty cursor in Song.randomize
This commit is contained in:
1 parent
cea45b35e1
commit
aa07a5264c
1 file changed
+2
-1
@@ -171,7 +171,8 @@ public class Song implements Parcelable {
|
||||
Cursor cursor = resolver.query(media, FILLED_PROJECTION, selection, null, null);
|
||||
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToPosition(ContextApplication.getRandom().nextInt(cursor.getCount()))) {
|
||||
int count = cursor.getCount();
|
||||
if (count > 0 && cursor.moveToPosition(ContextApplication.getRandom().nextInt(count))) {
|
||||
populate(cursor);
|
||||
flags |= FLAG_RANDOM;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user