Fix a cursor crash

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-06-16 12:02:50 +02:00
parent 91ec476f9a
commit 93643269a8

View File

@ -80,6 +80,8 @@ public class RingtoneSelectionController extends BaseController implements Flexi
private MediaPlayer mediaPlayer; private MediaPlayer mediaPlayer;
private Handler cancelMediaPlayerHandler; private Handler cancelMediaPlayerHandler;
private Cursor cursor;
public RingtoneSelectionController(Bundle args) { public RingtoneSelectionController(Bundle args) {
super(args); super(args);
setHasOptionsMenu(true); setHasOptionsMenu(true);
@ -180,7 +182,7 @@ public class RingtoneSelectionController extends BaseController implements Flexi
manager.setType(RingtoneManager.TYPE_NOTIFICATION); manager.setType(RingtoneManager.TYPE_NOTIFICATION);
} }
Cursor cursor = manager.getCursor(); cursor = manager.getCursor();
NotificationSoundItem notificationSoundItem; NotificationSoundItem notificationSoundItem;
@ -212,8 +214,6 @@ public class RingtoneSelectionController extends BaseController implements Flexi
} }
} }
} }
cursor.close();
} }
adapter.updateDataSet(abstractFlexibleItemList, true); adapter.updateDataSet(abstractFlexibleItemList, true);
@ -299,6 +299,9 @@ public class RingtoneSelectionController extends BaseController implements Flexi
@Override @Override
public void onDestroy() { public void onDestroy() {
endMediaPlayer(); endMediaPlayer();
if (cursor != null) {
cursor.close();
}
super.onDestroy(); super.onDestroy();
} }