private Set<String> mExtensionsToConsider;
private ProgressDialog mProgressDialog;
+ private String mExportingFileName;
private Handler mHandler = new Handler();
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
mActualExportThread = new ActualExportThread(mFileName);
- String title = getString(R.string.exporting_contact_list_title);
- String message = getString(R.string.exporting_contact_list_message, mFileName);
- mProgressDialog = new ProgressDialog(ExportVCardActivity.this);
- mProgressDialog.setTitle(title);
- mProgressDialog.setMessage(message);
- mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- mProgressDialog.setOnCancelListener(mActualExportThread);
- mProgressDialog.show();
mActualExportThread.start();
+ showDialog(R.id.dialog_exporting_vcard);
}
}
}
private class ActualExportThread extends Thread
implements DialogInterface.OnCancelListener {
private PowerManager.WakeLock mWakeLock;
- private String mFileName;
private boolean mCanceled = false;
public ActualExportThread(String fileName) {
- mFileName = fileName;
+ mExportingFileName = fileName;
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(
PowerManager.SCREEN_DIM_WAKE_LOCK |
try {
OutputStream outputStream = null;
try {
- outputStream = new FileOutputStream(mFileName);
+ outputStream = new FileOutputStream(mExportingFileName);
} catch (FileNotFoundException e) {
final String errorReason =
getString(R.string.fail_reason_could_not_open_file,
- mFileName, e.getMessage());
+ mExportingFileName, e.getMessage());
shouldCallFinish = false;
mHandler.post(new ErrorReasonDisplayer(errorReason));
return;
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(R.string.no_sdcard_message)
.setPositiveButton(android.R.string.ok, mCancelListener);
+ return builder.create();
+ }
+ case R.id.dialog_exporting_vcard: {
+ return getExportingVCardDialog();
}
}
return super.onCreateDialog(id);
}
+ private Dialog getExportingVCardDialog() {
+ if (mProgressDialog == null) {
+ String title = getString(R.string.exporting_contact_list_title);
+ String message = getString(R.string.exporting_contact_list_message,
+ mExportingFileName);
+ mProgressDialog = new ProgressDialog(ExportVCardActivity.this);
+ mProgressDialog.setTitle(title);
+ mProgressDialog.setMessage(message);
+ mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ mProgressDialog.setOnCancelListener(mActualExportThread);
+ }
+ return mProgressDialog;
+ }
+
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
if (id == R.id.dialog_fail_to_export_with_reason) {