use of android.content.BroadcastReceiver in project Anki-Android by Ramblurr.
the class DeckOptions method registerExternalStorageListener.
/**
* finish when sd card is ejected
*/
private void registerExternalStorageListener() {
if (mUnmountReceiver == null) {
mUnmountReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(SdCardReceiver.MEDIA_EJECT)) {
finish();
}
}
};
IntentFilter iFilter = new IntentFilter();
iFilter.addAction(SdCardReceiver.MEDIA_EJECT);
registerReceiver(mUnmountReceiver, iFilter);
}
}
use of android.content.BroadcastReceiver in project Anki-Android by Ramblurr.
the class DeckPicker method registerExternalStorageListener.
/**
* Show/dismiss dialog when sd card is ejected/remounted (collection is saved by SdCardReceiver)
*/
private void registerExternalStorageListener() {
if (mUnmountReceiver == null) {
mUnmountReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (AnkiDroidApp.getSharedPrefs(getBaseContext()).getBoolean("internalMemory", false)) {
return;
}
if (intent.getAction().equals(SdCardReceiver.MEDIA_EJECT)) {
showDialog(DIALOG_SD_CARD_NOT_MOUNTED);
} else if (intent.getAction().equals(SdCardReceiver.MEDIA_MOUNT)) {
if (mNotMountedDialog != null && mNotMountedDialog.isShowing()) {
mNotMountedDialog.dismiss();
}
loadCollection();
}
}
};
IntentFilter iFilter = new IntentFilter();
iFilter.addAction(SdCardReceiver.MEDIA_EJECT);
iFilter.addAction(SdCardReceiver.MEDIA_MOUNT);
registerReceiver(mUnmountReceiver, iFilter);
}
}
use of android.content.BroadcastReceiver in project Anki-Android by Ramblurr.
the class CardEditor method registerExternalStorageListener.
// ----------------------------------------------------------------------------
// CUSTOM METHODS
// ----------------------------------------------------------------------------
/**
* finish when sd card is ejected
*/
private void registerExternalStorageListener() {
if (mUnmountReceiver == null) {
mUnmountReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(SdCardReceiver.MEDIA_EJECT)) {
finish();
}
}
};
IntentFilter iFilter = new IntentFilter();
iFilter.addAction(SdCardReceiver.MEDIA_EJECT);
registerReceiver(mUnmountReceiver, iFilter);
}
}
use of android.content.BroadcastReceiver in project Anki-Android by Ramblurr.
the class CramDeckOptions method registerExternalStorageListener.
/**
* finish when sd card is ejected
*/
private void registerExternalStorageListener() {
if (mUnmountReceiver == null) {
mUnmountReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(SdCardReceiver.MEDIA_EJECT)) {
finish();
}
}
};
IntentFilter iFilter = new IntentFilter();
iFilter.addAction(SdCardReceiver.MEDIA_EJECT);
registerReceiver(mUnmountReceiver, iFilter);
}
}
use of android.content.BroadcastReceiver in project Anki-Android by Ramblurr.
the class StudyOptionsActivity method registerExternalStorageListener.
/**
* Show/dismiss dialog when sd card is ejected/remounted (collection is saved by SdCardReceiver)
*/
private void registerExternalStorageListener() {
if (mUnmountReceiver == null) {
mUnmountReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(SdCardReceiver.MEDIA_EJECT)) {
mNotMountedDialog = StyledOpenCollectionDialog.show(StudyOptionsActivity.this, getResources().getString(R.string.sd_card_not_mounted), new OnCancelListener() {
@Override
public void onCancel(DialogInterface arg0) {
finish();
}
});
} else if (intent.getAction().equals(SdCardReceiver.MEDIA_MOUNT)) {
if (mNotMountedDialog != null && mNotMountedDialog.isShowing()) {
mNotMountedDialog.dismiss();
}
mCurrentFragment.reloadCollection();
}
}
};
IntentFilter iFilter = new IntentFilter();
iFilter.addAction(SdCardReceiver.MEDIA_EJECT);
iFilter.addAction(SdCardReceiver.MEDIA_MOUNT);
registerReceiver(mUnmountReceiver, iFilter);
}
}
Aggregations