List of usage examples for android.app ProgressDialog STYLE_HORIZONTAL
int STYLE_HORIZONTAL
To view the source code for android.app ProgressDialog STYLE_HORIZONTAL.
Click Source Link
From source file:com.esri.arcgisruntime.sample.editandsyncfeatures.MainActivity.java
/** * Create a progress dialog to show sync state *//*from w ww . j a va2s .c o m*/ private void createProgressDialog(Job job) { ProgressDialog syncProgressDialog = new ProgressDialog(this); syncProgressDialog.setTitle("Sync Geodatabase Job"); syncProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); syncProgressDialog.setCanceledOnTouchOutside(false); syncProgressDialog.show(); job.addProgressChangedListener(() -> syncProgressDialog.setProgress(job.getProgress())); job.addJobDoneListener(syncProgressDialog::dismiss); }
From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java
private void initializeUpdatesFoundDialogButtons(final AlertDialog.Builder builder, final Update update) { if (!update.forceExit) { Intent launchIntent = null;//w w w .java2 s. c o m try { if (isAlreadyInstalled(activity, update)) { launchIntent = activity.getPackageManager().getLaunchIntentForPackage(update.targetPackageName); } } catch (Exception e) { Log.e("Couldn't get launch intent for application: " + update.targetPackageName, e); } if (launchIntent != null) { final Intent i = launchIntent; builder.setPositiveButton(R.string.launch, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.startActivity(i); onExit(); } }); } else { builder.setPositiveButton(R.string.install, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { updateProgressDialog = new ProgressDialog(activity); updateProgressDialog.setMax(100); updateProgressDialog.setTitle(getActivity().getString(R.string.downloading_new_version)); updateProgressDialog.setCancelable(false); updateProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); updateProgressDialog.setIndeterminate(false); UpdaterDialogManager.this.update = update; updateProgressDialog.show(); updateManager.applyUpdate(activity, update, UpdaterDialogManager.this); } }); } } if (update.forceExit || update.forceUpdate) { builder.setNegativeButton(R.string.exit_application, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onExit(); } }); } else { builder.setNegativeButton(R.string.remind_me_later, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onCompleted(); } }); } }
From source file:com.getkickbak.plugin.NotificationPlugin.java
/** * Show the progress dialog.//from w ww .j a v a2 s.co m * * @param title * Title of the dialog * @param message * The message of the dialog */ public synchronized void progressStart(final String title, final String message) { if (this.progressDialog != null) { this.progressDialog.dismiss(); this.progressDialog = null; } final NotificationPlugin notification = this; final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { notification.progressDialog = new ProgressDialog(cordova.getActivity()); notification.progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); notification.progressDialog.setTitle(title); notification.progressDialog.setMessage(message); notification.progressDialog.setCancelable(true); notification.progressDialog.setMax(100); notification.progressDialog.setProgress(0); notification.progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { notification.progressDialog = null; } }); notification.progressDialog.show(); } }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:edu.cnu.PowerTutor.ui.PowerViewer.java
/** * ? ? ? ? ?. ? ? ? ? ? ? .// www. j a va 2 s. co m */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_PROBABILITY_PROGRESS: mWriteProgressDialog = new ProgressDialog(this); mWriteProgressDialog.setIcon(android.R.drawable.ic_dialog_info); mWriteProgressDialog.setTitle(getString(R.string.progress_title)); mWriteProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mWriteProgressDialog.setCancelable(false); mWriteProgressDialog.setMessage(getString(R.string.write_progress_message)); // progress bar ? . mWriteProgressDialog.setMax(PROGRESS_MAX); Log.d(TAG, "onCreateDialog pass"); return mWriteProgressDialog; } return null; }
From source file:org.sufficientlysecure.keychain.ui.ImportKeysActivity.java
/** * Import keys with mImportData/* ww w. j a v a 2 s. c o m*/ */ public void importKeys() { if (mImportData != null || mImportFilename != null) { Log.d(Constants.TAG, "importKeys started"); // Send all information needed to service to import key in other thread Intent intent = new Intent(this, KeychainIntentService.class); intent.putExtra(KeychainIntentService.EXTRA_ACTION, KeychainIntentService.ACTION_IMPORT_KEYRING); // fill values for this action Bundle data = new Bundle(); // TODO: check for key type? // data.putInt(ApgIntentService.IMPORT_KEY_TYPE, Id.type.secret_key); if (mImportData != null) { data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES); data.putByteArray(KeychainIntentService.IMPORT_BYTES, mImportData); } else { data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_FILE); data.putString(KeychainIntentService.IMPORT_FILENAME, mImportFilename); } intent.putExtra(KeychainIntentService.EXTRA_DATA, data); // Message is received after importing is done in ApgService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, R.string.progress_importing, ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { // handle messages by standard ApgHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { // get returned data bundle Bundle returnData = message.getData(); int added = returnData.getInt(KeychainIntentService.RESULT_IMPORT_ADDED); int updated = returnData.getInt(KeychainIntentService.RESULT_IMPORT_UPDATED); int bad = returnData.getInt(KeychainIntentService.RESULT_IMPORT_BAD); String toastMessage; if (added > 0 && updated > 0) { toastMessage = getString(R.string.keysAddedAndUpdated, added, updated); } else if (added > 0) { toastMessage = getString(R.string.keysAdded, added); } else if (updated > 0) { toastMessage = getString(R.string.keysUpdated, updated); } else { toastMessage = getString(R.string.noKeysAddedOrUpdated); } Toast.makeText(ImportKeysActivity.this, toastMessage, Toast.LENGTH_SHORT).show(); if (bad > 0) { AlertDialog.Builder alert = new AlertDialog.Builder(ImportKeysActivity.this); alert.setIcon(android.R.drawable.ic_dialog_alert); alert.setTitle(R.string.warning); alert.setMessage(ImportKeysActivity.this.getString(R.string.badKeysEncountered, bad)); alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alert.setCancelable(true); alert.create().show(); } else if (mDeleteAfterImport) { // everything went well, so now delete, if that was turned on DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment .newInstance(mImportFilename); deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog"); } } }; }; // Create a new Messenger for the communication back Messenger messenger = new Messenger(saveHandler); intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); // show progress dialog saveHandler.showProgressDialog(this); // start service with intent startService(intent); } else { Toast.makeText(this, R.string.error_nothingImport, Toast.LENGTH_LONG).show(); } }
From source file:brama.com.hearthum.waveform.WaveformFragment.java
protected void loadFromFile() { mFile = new File(mFilename); mLoadingLastUpdateTime = System.currentTimeMillis(); mLoadingKeepGoing = true;// ww w. j av a 2s . c o m mProgressDialog = new ProgressDialog(getActivity()); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setTitle(R.string.progress_dialog_loading); mProgressDialog.setCancelable(true); mProgressDialog.setOnCancelListener((DialogInterface dialog) -> mLoadingKeepGoing = false); mProgressDialog.show(); final CheapSoundFile.ProgressListener listener = (double fractionComplete) -> { long now = System.currentTimeMillis(); if (now - mLoadingLastUpdateTime > 100) { mProgressDialog.setProgress((int) (mProgressDialog.getMax() * fractionComplete)); mLoadingLastUpdateTime = now; } return mLoadingKeepGoing; }; // Create the MediaPlayer in a background thread new Thread() { public void run() { try { MediaPlayer player = new MediaPlayer(); player.setDataSource(mFile.getAbsolutePath()); player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.prepare(); mPlayer = player; } catch (final java.io.IOException e) { Log.e(TAG, "Error while creating media player", e); } } }.start(); // Load the sound file in a background thread new Thread() { public void run() { try { mSoundFile = CheapSoundFile.create(mFile.getAbsolutePath(), listener); } catch (final Exception e) { Log.e(TAG, "Error while loading sound file", e); mProgressDialog.dismiss(); mInfo.setText(e.toString()); return; } if (mLoadingKeepGoing) { mHandler.post(() -> finishOpeningSoundFile()); } } }.start(); }
From source file:org.akvo.caddisfly.sensor.ec.CalibrateSensorActivity.java
private void calibratePoint(final double[] calibrations, final int index) { progressDialog = new ProgressDialog(this); progressDialog.setTitle(R.string.pleaseWait); progressDialog.setMessage(getString(R.string.calibrating)); progressDialog.setIndeterminate(false); progressDialog.setMax(PROGRESS_MAX); progressDialog.setCancelable(false); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.show();//from www .ja va 2 s .com final Handler progressHandler = new Handler(); Runnable progressRunnable = new Runnable() { public void run() { progressDialog.incrementProgressBy(1); if (progressDialog.getProgress() == progressDialog.getMax()) { progressDialog.dismiss(); } else { progressHandler.postDelayed(this, 1000); } } }; progressHandler.postDelayed(progressRunnable, 100); new Handler().postDelayed(new Runnable() { @Override public void run() { String requestCommand = "SET POINT" + calibrationIndex + " " + calibrations[index] + LINE_FEED; usbService.write(requestCommand.getBytes(StandardCharsets.UTF_8)); (new Handler()).postDelayed(new Runnable() { public void run() { if (calibrationIndex > 5) { AlertUtil.showAlert(mContext, R.string.calibrationSuccessful, R.string.sensorCalibrated, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); finish(); } }, null, null); } else { displayInformation(calibrationIndex); } } }, 1000); } }, CALIBRATION_DELAY_MILLIS); }
From source file:com.soubw.other.WaveformFragment.java
protected void loadFromFile() { mFile = new File(mFilename); mLoadingLastUpdateTime = System.currentTimeMillis(); mLoadingKeepGoing = true;/* w w w . jav a2s . c om*/ mProgressDialog = new ProgressDialog(getActivity()); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setTitle(R.string.progress_dialog_loading); mProgressDialog.setCancelable(true); mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mLoadingKeepGoing = false; } }); mProgressDialog.show(); final CheapSoundFile.ProgressListener listener = new CheapSoundFile.ProgressListener() { @Override public boolean reportProgress(double fractionComplete) { long now = System.currentTimeMillis(); if (now - mLoadingLastUpdateTime > 100) { mProgressDialog.setProgress((int) (mProgressDialog.getMax() * fractionComplete)); mLoadingLastUpdateTime = now; } return mLoadingKeepGoing; } }; // Create the MediaPlayer in a background thread new Thread() { public void run() { try { MediaPlayer player = new MediaPlayer(); player.setDataSource(mFile.getAbsolutePath()); player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.prepare(); mPlayer = player; } catch (final java.io.IOException e) { Log.e(TAG, "Error while creating media player", e); } } }.start(); // Load the sound file in a background thread new Thread() { public void run() { try { mSoundFile = CheapSoundFile.create(mFile.getAbsolutePath(), listener); } catch (final Exception e) { Log.e(TAG, "Error while loading sound file", e); mProgressDialog.dismiss(); mInfo.setText(e.toString()); return; } if (mLoadingKeepGoing) { mHandler.post(new Runnable() { @Override public void run() { finishOpeningSoundFile(); } }); } } }.start(); }
From source file:id.nci.stm_9.ImportKeysActivity.java
/** * Import keys with mImportData/*ww w . java 2s . c om*/ */ public void importKeys() { if (mListFragment.getKeyBytes() != null || mListFragment.getImportFilename() != null) { Log.d("stm-9", "importKeys started"); // Send all information needed to service to import key in other thread Intent intent = new Intent(this, KeychainIntentService.class); intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING); // fill values for this action Bundle data = new Bundle(); // get selected key ids List<ImportKeysListEntry> listEntries = mListFragment.getData(); ArrayList<Long> selectedKeyIds = new ArrayList<Long>(); for (ImportKeysListEntry entry : listEntries) { if (entry.isSelected()) { selectedKeyIds.add(entry.keyId); } } data.putSerializable(KeychainIntentService.IMPORT_KEY_LIST, selectedKeyIds); if (mListFragment.getKeyBytes() != null) { data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES); data.putByteArray(KeychainIntentService.IMPORT_BYTES, mListFragment.getKeyBytes()); } else { data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_FILE); data.putString(KeychainIntentService.IMPORT_FILENAME, mListFragment.getImportFilename()); } intent.putExtra(KeychainIntentService.EXTRA_DATA, data); // Message is received after importing is done in ApgService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, R.string.progress_importing, ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { // handle messages by standard ApgHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { // get returned data bundle Bundle returnData = message.getData(); int added = returnData.getInt(KeychainIntentService.RESULT_IMPORT_ADDED); int updated = returnData.getInt(KeychainIntentService.RESULT_IMPORT_UPDATED); // int bad = returnData.getInt(KeychainIntentService.RESULT_IMPORT_BAD); String toastMessage; if (added > 0 && updated > 0) { toastMessage = getString(R.string.keys_added_and_updated, added, updated); } else if (added > 0) { toastMessage = getString(R.string.keys_added, added); } else if (updated > 0) { toastMessage = getString(R.string.keys_updated, updated); } else { toastMessage = getString(R.string.no_keys_added_or_updated); } Toast.makeText(ImportKeysActivity.this, toastMessage, Toast.LENGTH_SHORT).show(); // if (bad > 0) { // AlertDialog.Builder alert = new AlertDialog.Builder( // ImportKeysActivity.this); // // alert.setIcon(android.R.drawable.ic_dialog_alert); // alert.setTitle(R.string.warning); // alert.setMessage(ImportKeysActivity.this.getString( // R.string.bad_keys_encountered, bad)); // // alert.setPositiveButton(android.R.string.ok, // new DialogInterface.OnClickListener() { // public void onClick(DialogInterface dialog, int id) { // dialog.cancel(); // } // }); // alert.setCancelable(true); // alert.create().show(); // } else if (mDeleteAfterImport) { // // everything went well, so now delete, if that was turned on // DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment // .newInstance(mListFragment.getImportFilename()); // deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog"); // } } }; }; // Create a new Messenger for the communication back Messenger messenger = new Messenger(saveHandler); intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); // show progress dialog saveHandler.showProgressDialog(this); // start service with intent startService(intent); } else { Toast.makeText(this, R.string.error_nothing_import, Toast.LENGTH_LONG).show(); } }
From source file:ac.robinson.mediaphone.MediaPhoneActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case R.id.dialog_importing_in_progress: ProgressDialog importDialog = new ProgressDialog(MediaPhoneActivity.this); importDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); importDialog.setMessage(getString(R.string.import_progress)); importDialog.setCancelable(false); mImportFramesProgressDialog = importDialog; mImportFramesDialogShown = true; return importDialog; case R.id.dialog_export_narrative_in_progress: ProgressDialog exportDialog = new ProgressDialog(MediaPhoneActivity.this); exportDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); exportDialog.setMessage(getString(R.string.background_task_progress)); exportDialog.setCancelable(false); exportDialog.setIndeterminate(true); mExportNarrativeDialogShown = true; return exportDialog; case R.id.dialog_mov_creator_in_progress: ProgressDialog movDialog = new ProgressDialog(MediaPhoneActivity.this); movDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); movDialog.setMessage(getString(R.string.mov_export_task_progress)); movDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.mov_export_run_in_background), new DialogInterface.OnClickListener() { @Override/*from w w w.j a va 2s . c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); mExportVideoDialogShown = false; } }); movDialog.setCancelable(false); movDialog.setIndeterminate(true); mExportVideoDialogShown = true; return movDialog; case R.id.dialog_background_runner_in_progress: ProgressDialog runnerDialog = new ProgressDialog(MediaPhoneActivity.this); runnerDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); runnerDialog.setMessage(getString(R.string.background_task_progress)); runnerDialog.setCancelable(false); runnerDialog.setIndeterminate(true); mBackgroundRunnerDialogShown = true; return runnerDialog; default: return super.onCreateDialog(id); } }