@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_MAP_VERSION_UPDATE: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.map_version_changed_info); builder.setPositiveButton( R.string.button_upgrade_osmandplus, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:net.osmand.plus")); try { startActivity(intent); } catch (ActivityNotFoundException e) { } } }); builder.setNegativeButton( R.string.default_buttons_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_MAP_VERSION_UPDATE); } }); return builder.create(); case DIALOG_PROGRESS_LIST: ProgressDialog dialog = new ProgressDialog(this); dialog.setTitle(R.string.downloading); dialog.setMessage(getString(R.string.downloading_list_indexes)); dialog.setCancelable(true); return dialog; case DIALOG_PROGRESS_FILE: ProgressDialogImplementation progress = ProgressDialogImplementation.createProgressDialog( DownloadIndexActivity.this, getString(R.string.downloading), getString(R.string.downloading_file), ProgressDialog.STYLE_HORIZONTAL, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { makeSureUserCancelDownload(dialog); } }); progressFileDlg = progress.getDialog(); progressFileDlg.setOnDismissListener( new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { downloadFileHelper.setInterruptDownloading(true); } }); return progress.getDialog(); } return null; }
@Override public boolean onPreferenceClick(Preference preference) { if (preference.getKey().equals(OsmandSettings.LOCAL_INDEXES)) { startActivity(new Intent(this, LocalIndexesActivity.class)); return true; } else if (preference == saveCurrentTrack) { SavingTrackHelper helper = new SavingTrackHelper(this); if (helper.hasDataToSave()) { progressDlg = ProgressDialog.show( this, getString(R.string.saving_gpx_tracks), getString(R.string.saving_gpx_tracks), true); final ProgressDialogImplementation impl = new ProgressDialogImplementation(progressDlg); impl.setRunnable( "SavingGPX", new Runnable() { //$NON-NLS-1$ @Override public void run() { try { SavingTrackHelper helper = new SavingTrackHelper(SettingsActivity.this); helper.saveDataToGpx(); helper.close(); } finally { if (progressDlg != null) { progressDlg.dismiss(); progressDlg = null; } } } }); impl.run(); } else { helper.close(); } return true; } return false; }
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_PROGRESS_UPLOAD: return ProgressDialogImplementation.createProgressDialog( LocalOpenstreetmapActivity.this, getString(R.string.uploading), getString(R.string.local_openstreetmap_uploading), ProgressDialog.STYLE_HORIZONTAL) .getDialog(); } return null; }
public void reloadIndexes() { reloadVoiceListPreference(getPreferenceScreen()); progressDlg = ProgressDialog.show( this, getString(R.string.loading_data), getString(R.string.reading_indexes), true); final ProgressDialogImplementation impl = new ProgressDialogImplementation(progressDlg); impl.setRunnable( "Initializing app", new Runnable() { //$NON-NLS-1$ @Override public void run() { try { showWarnings(getMyApplication().getResourceManager().reloadIndexes(impl)); } finally { if (progressDlg != null) { progressDlg.dismiss(); progressDlg = null; } } } }); impl.run(); }