List of usage examples for android.app ProgressDialog setProgressStyle
public void setProgressStyle(int style)
From source file:com.kkbox.toolkit.dialog.KKDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { DialogInterface.OnClickListener positiveListener = new DialogInterface.OnClickListener() { @Override//ww w. jav a 2s .c om public void onClick(DialogInterface dialog, int id) { if (!isDismissed) { if (listener != null) { listener.onPositive(); } onDialogFinishedByUser(); isDismissed = true; } } }; DialogInterface.OnClickListener neutralListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (!isDismissed) { if (listener != null) { listener.onNeutral(); } onDialogFinishedByUser(); isDismissed = true; } } }; DialogInterface.OnClickListener negativeListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (!isDismissed) { if (listener != null) { listener.onNegative(); } onDialogFinishedByUser(); isDismissed = true; } } }; switch (dialogType) { case Type.PROGRESSING_DIALOG: ProgressDialog progressDialog; if (theme != -1) { progressDialog = new ProgressDialog(getActivity(), theme); } else { progressDialog = new ProgressDialog(getActivity()); } progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setMessage(message); progressDialog.setIndeterminate(true); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(listener != null); return progressDialog; case Type.ALERT_DIALOG: AlertDialog.Builder builder; AlertDialog alertDialog; if (theme != -1) { builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme)); } else { builder = new AlertDialog.Builder(getActivity()); } builder.setMessage(message); builder.setTitle(title); builder.setPositiveButton(positiveButtonText, positiveListener); alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside); return alertDialog; case Type.THREE_CHOICE_DIALOG: if (theme != -1) { builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme)); } else { builder = new AlertDialog.Builder(getActivity()); } builder.setMessage(message); builder.setTitle(title); builder.setPositiveButton(positiveButtonText, positiveListener); builder.setNeutralButton(neutralButtonText, neutralListener); builder.setNegativeButton(negativeButtonText, negativeListener); alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside); return alertDialog; case Type.YES_OR_NO_DIALOG: if (theme != -1) { builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme)); } else { builder = new AlertDialog.Builder(getActivity()); } builder.setMessage(message); builder.setTitle(title); builder.setPositiveButton(positiveButtonText, positiveListener); builder.setNegativeButton(negativeButtonText, negativeListener); alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside); return alertDialog; case Type.SELECT_DIALOG: if (theme != -1) { builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme)); } else { builder = new AlertDialog.Builder(getActivity()); } builder.setMessage(message); builder.setTitle(title); builder.setSingleChoiceItems(entries, selectedIndex, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (!isDismissed) { if (listener != null) { listener.onEvent(id); } dismiss(); onDialogFinishedByUser(); isDismissed = true; } } }); builder.setNegativeButton(negativeButtonText, negativeListener); alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside); return alertDialog; case Type.CUSTOMIZE_DIALOG: if (theme != -1) { builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme)); } else { builder = new AlertDialog.Builder(getActivity()); } if (customizeView != null && customizeView.getParent() != null) { ((ViewGroup) customizeView.getParent()).removeView(customizeView); } builder.setView(customizeView); if (!TextUtils.isEmpty(title)) { builder.setTitle(title); } if (!TextUtils.isEmpty(positiveButtonText)) { builder.setPositiveButton(positiveButtonText, positiveListener); } if (!TextUtils.isEmpty(neutralButtonText)) { builder.setNeutralButton(neutralButtonText, neutralListener); } if (!TextUtils.isEmpty(negativeButtonText)) { builder.setNegativeButton(negativeButtonText, negativeListener); } alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside); return alertDialog; case Type.CUSTOMIZE_FULLSCREEN_DIALOG: Dialog dialog; if (theme != -1) { dialog = new Dialog(getActivity(), theme); } else { dialog = new Dialog(getActivity(), android.R.style.Theme_NoTitleBar); } if (customizeView != null && customizeView.getParent() != null) { ((ViewGroup) customizeView.getParent()).removeView(customizeView); } dialog.setContentView(customizeView); return dialog; } return null; }
From source file:org.exobel.routerkeygen.ui.Preferences.java
protected Dialog onCreateDialog(int id) { AlertDialog.Builder builder = new Builder(this); switch (id) { case DIALOG_ABOUT: { LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.about_dialog, (ViewGroup) findViewById(R.id.tabhost)); TabHost tabs = (TabHost) layout.findViewById(R.id.tabhost); tabs.setup();//from ww w . j a va2 s . c om TabSpec tspec1 = tabs.newTabSpec("about"); tspec1.setIndicator(getString(R.string.pref_about)); tspec1.setContent(R.id.text_about_scroll); TextView text = ((TextView) layout.findViewById(R.id.text_about)); text.setMovementMethod(LinkMovementMethod.getInstance()); text.append(VERSION + "\n" + LAUNCH_DATE); tabs.addTab(tspec1); TabSpec tspec2 = tabs.newTabSpec("credits"); tspec2.setIndicator(getString(R.string.dialog_about_credits)); tspec2.setContent(R.id.about_credits_scroll); ((TextView) layout.findViewById(R.id.about_credits)) .setMovementMethod(LinkMovementMethod.getInstance()); tabs.addTab(tspec2); TabSpec tspec3 = tabs.newTabSpec("license"); tspec3.setIndicator(getString(R.string.dialog_about_license)); tspec3.setContent(R.id.about_license_scroll); ((TextView) layout.findViewById(R.id.about_license)) .setMovementMethod(LinkMovementMethod.getInstance()); tabs.addTab(tspec3); builder.setNeutralButton(R.string.bt_close, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_ABOUT); } }); builder.setView(layout); break; } case DIALOG_ASK_DOWNLOAD: { DialogInterface.OnClickListener diOnClickListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Check if we have the latest dictionary version. try { checkCurrentDictionary(); } catch (Exception e) { e.printStackTrace(); } } }; builder.setTitle(R.string.pref_download); builder.setMessage(R.string.msg_dicislarge); builder.setCancelable(false); builder.setPositiveButton(android.R.string.yes, diOnClickListener); builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DIALOG_ASK_DOWNLOAD); } }); break; } case DIALOG_UPDATE_NEEDED: { builder.setTitle(R.string.update_title) .setMessage(getString(R.string.update_message, lastVersion.version)) .setNegativeButton(R.string.bt_close, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_UPDATE_NEEDED); } }).setPositiveButton(R.string.bt_website, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(lastVersion.url))); } }); break; } case DIALOG_WAIT: { ProgressDialog pbarDialog = new ProgressDialog(Preferences.this); pbarDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pbarDialog.setMessage(getString(R.string.msg_wait)); return pbarDialog; } case DIALOG_ERROR_TOO_ADVANCED: { builder.setTitle(R.string.msg_error).setMessage(R.string.msg_err_online_too_adv); break; } case DIALOG_ERROR: { builder.setTitle(R.string.msg_error).setMessage(R.string.msg_err_unkown); break; } case DIALOG_CHANGELOG: { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); ChangeLogListView chgList = (ChangeLogListView) layoutInflater.inflate(R.layout.dialog_changelog, (ViewGroup) this.getWindow().getDecorView().getRootView(), false); builder.setTitle(R.string.pref_changelog).setView(chgList).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); break; } } return builder.create(); }
From source file:com.artur.softwareproject.Main.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.disconnect: if (!recording) { stopService(bluetoothServiceIntent); final ProgressDialog disconnectingDialog = new ProgressDialog(Main.this); disconnectingDialog.setMessage("Disconnecting..."); disconnectingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); disconnectingDialog.setCancelable(false); disconnectingDialog.show();/* w w w . j a va 2s. c om*/ disconDialog = disconnectingDialog; final DisconnectHandlerClass disconnectHandler = new DisconnectHandlerClass(this); disconnectThread = new Thread(new Runnable() { @Override public void run() { int stop = 0; while (stop == 0) { stop = getDisconnect(); sleep(1500); } disconnectHandler.sendEmptyMessage(0); } }); disconnectThread.start(); } return true; case R.id.record_data: Log.d(TAG, "Record button was Pressed. Gps status: " + gpsStatus); if (!recording && gpsStatus) { Intent resetIntent = new Intent(); resetIntent.putExtra("reset", ""); resetIntent.setAction("resetFilter"); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(resetIntent); item.setIcon(R.drawable.ic_action_stop); Toast.makeText(getApplicationContext(), "Start recording data", Toast.LENGTH_LONG).show(); currentTime = System.currentTimeMillis(); recordClock.setVisibility(View.VISIBLE); Animation a = AnimationUtils.loadAnimation(this, R.anim.textslide); TextView tv = (TextView) findViewById(R.id.recordClock); tv.startAnimation(a); recording = true; if (!rBound) { Intent intent = new Intent(this, RecordService.class); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); } } else if (recording) { stopRecording(); } return true; case R.id.vr_menu: if (!recording) { Intent vrIntent = new Intent(Main.this, VRmenuMap.class); Main.this.startActivity(vrIntent); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:org.alfresco.mobile.android.application.fragments.operations.OperationWaitingDialogFragment.java
public Dialog onCreateDialog(final Bundle savedInstanceState) { setRetainInstance(true);/* w ww . ja v a2 s. c o m*/ if (getArguments() != null) { operationType = getArguments().getInt(PARAM_TYPEID); intentId = getArguments().getString(PARAM_INTENTID); iconId = getArguments().getInt(PARAM_ICONID); title = getArguments().getString(PARAM_TITLEID); message = getArguments().getString(PARAM_MESSAGEID); parent = getArguments().getParcelable(PARAM_NODEID); nbItems = getArguments().getInt(PARAM_SIZE); } ProgressDialog dialog = new ProgressDialog(getActivity()); if (iconId == 0) { iconId = R.drawable.ic_alfresco_logo; } dialog.setIcon(iconId); dialog.setTitle(title); if (message == null) { message = getString(R.string.waiting_operations); } dialog.setMessage(message); boolean indeterminate = true; if (nbItems > 0) { dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgress(0); dialog.setMax(nbItems); indeterminate = false; } else { dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); } dialog.setIndeterminate(indeterminate); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); getActivity().getLoaderManager().restartLoader(this.hashCode(), null, this); return dialog; }
From source file:com.cellobject.oikos.FormActivity.java
/** * For API level 8 or newer. //from ww w . ja v a 2 s . c o m */ public Dialog onCreateDialog(final int id, final Bundle args) { if (id == SUBMITTING_DIALOG) { final ProgressDialog dlg = new ProgressDialog(this); dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER); dlg.setMessage(getText(R.string.submitting)); dlg.setIndeterminate(true); return dlg; } return null; }
From source file:com.cellobject.oikos.FormActivity.java
/** * For API level lower than 8. /*from w w w . j a v a 2s . co m*/ */ public Dialog onCreateDialog(final int id) { if (id == SUBMITTING_DIALOG) { final ProgressDialog dlg = new ProgressDialog(this); dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER); dlg.setMessage(getText(R.string.submitting)); dlg.setIndeterminate(true); return dlg; } return null; }
From source file:net.gerosyab.dailylog.activity.MainActivity.java
private void exportCategory(final long id) { //?? ? ?? csv //? ?? ?? /*from ww w. jav a 2s . c om*/ // ? ? ? ? Category category = categories.get((int) id); ProgressDialog progressDialog = new ProgressDialog(MainActivity.this); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setTitle("Exporting data [" + category.getName() + "]"); progressDialog.show(); String filename = category.getName() + "" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".data"; FileOutputStream outputStream = null; File resultFilePath = null; File resultFile = null; CSVWriter cw = null; try { resultFile = new File(context.getCacheDir(), filename); outputStream = new FileOutputStream(resultFile.getAbsolutePath()); // cw = new CSVWriter(new OutputStreamWriter(outputStream, "UTF-8"),'\t', '"'); cw = new CSVWriter(new OutputStreamWriter(outputStream, "UTF-8"), ',', '"'); // Export Data String[] metaDataStr = { "Version:" + AppDatabase.VERSION, "Name:" + category.getName(), "Unit:" + category.getUnit(), "Type:" + category.getRecordType(), "DefaultValue:" + category.getDefaultValue(), "Columns:date(yyyy-MM-dd 24HH:mm:ss)/value(boolean|numeric|string)" }; cw.writeNext(metaDataStr); List<Record> records = category.getRecordsOrderByDateAscending(realm); for (Record record : records) { String value = null; if (category.getRecordType() == StaticData.RECORD_TYPE_BOOLEAN) { value = "true"; } else if (category.getRecordType() == StaticData.RECORD_TYPE_NUMBER) { value = "" + record.getNumber(); } else if (category.getRecordType() == StaticData.RECORD_TYPE_MEMO) { value = record.getString(); } String[] s = { record.getDateString(StaticData.fmtForBackup), value }; cw.writeNext(s); } cw.close(); outputStream.close(); progressDialog.dismiss(); Uri fileUri = FileProvider.getUriForFile(context, "net.gerosyab.dailylog.fileprovider", resultFile); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri); shareIntent.setType("text/plain"); startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to))); } catch (UnsupportedEncodingException e) { Log.e("DailyLog", e.getMessage()); e.printStackTrace(); } catch (IllegalArgumentException e) { Log.e("DailyLog", e.getMessage()); e.printStackTrace(); } catch (Exception e) { Log.e("DailyLog", e.getMessage()); e.printStackTrace(); } finally { progressDialog.dismiss(); } }
From source file:com.esri.arcgisruntime.generateofflinemapoverrides.MainActivity.java
/** * Shows a progress dialog for the given job. * * @param job to track progress from/*from www.jav a2 s .c o m*/ */ private void showProgressDialog(Job job) { // create a progress dialog to show download progress ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setTitle("Generate Offline Map Job"); progressDialog.setMessage("Taking map offline..."); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setIndeterminate(false); progressDialog.setProgress(0); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", (dialog, which) -> job.cancel()); progressDialog.show(); // show the job's progress with the progress dialog job.addProgressChangedListener(() -> progressDialog.setProgress(job.getProgress())); // dismiss dialog when job is done job.addJobDoneListener(progressDialog::dismiss); }
From source file:com.android.gallery3d.ingest.IngestActivity.java
private void updateProgressDialog() { ProgressDialog dialog = getProgressDialog(); boolean indeterminate = (mProgressState.max == 0); dialog.setIndeterminate(indeterminate); dialog.setProgressStyle(indeterminate ? ProgressDialog.STYLE_SPINNER : ProgressDialog.STYLE_HORIZONTAL); if (mProgressState.title != null) { dialog.setTitle(mProgressState.title); }// www. ja va2 s. c om if (mProgressState.message != null) { dialog.setMessage(mProgressState.message); } if (!indeterminate) { dialog.setProgress(mProgressState.current); dialog.setMax(mProgressState.max); } if (!dialog.isShowing()) { dialog.show(); } }
From source file:org.alfresco.mobile.android.ui.operation.OperationWaitingDialogFragment.java
public Dialog onCreateDialog(final Bundle savedInstanceState) { if (getArguments() != null) { operationType = getArguments().getInt(ARGUMENT_TYPEID); intentId = getArguments().getString(ARGUMENT_INTENTID); iconId = getArguments().getInt(ARGUMENT_ICONID); title = getArguments().getString(ARGUMENT_TITLEID); message = getArguments().getString(ARGUMENT_MESSAGEID); parent = getArguments().getParcelable(ARGUMENT_NODEID); nbItems = getArguments().getInt(ARGUMENT_SIZE); operationId = getArguments().getString(ARGUMENT_OPERATIONID); }// ww w . j a v a2 s . c o m ProgressDialog dialog = new ProgressDialog(getActivity()); if (iconId == 0) { iconId = R.drawable.ic_application_logo; } dialog.setIcon(iconId); dialog.setTitle(title); if (message == null) { message = getString(R.string.waiting_operations); } dialog.setMessage(message); boolean indeterminate = true; if (nbItems > 0) { dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgress(0); dialog.setMax(nbItems); indeterminate = false; } else { dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); } dialog.setIndeterminate(indeterminate); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (operationId != null) { Operator.with(getActivity()).cancel(operationId); } dialog.dismiss(); } }); getActivity().getLoaderManager().restartLoader(this.hashCode(), null, this); return dialog; }