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.nuvolect.securesuite.data.SqlSyncTest.java
private void pingPongProgress(Activity act) { m_pingPongProgressDialog = new ProgressDialog(m_act); m_pingPongProgressDialog.setTitle("Ping Pong Test In Progress"); m_pingPongProgressDialog.setMessage("Starting test..."); m_pingPongProgressDialog.setMax(SqlSyncTest.MAX_PING_PONG_TESTS); m_pingPongProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); m_pingPongProgressDialog.setIndeterminate(false); m_pingPongProgressDialog.setCancelable(false); m_pingPongProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SqlSyncTest.getInstance().stopTest(); m_pingPongProgressDialog.cancel(); return; }//from w ww .j a va 2s .c o m }); m_pingPongProgressDialog.setProgress(0); m_pingPongProgressDialog.show(); }
From source file:com.nextgis.woody.activity.MainActivity.java
protected void loadData() { final MainApplication app = (MainApplication) getApplication(); final Account account = app.getAccount(Constants.ACCOUNT_NAME); class DownloadTask extends AsyncTask<Account, Integer, String> { private ProgressDialog mProgressDialog; private String mCurrentMessage; @Override/*from www .j a v a 2s . com*/ protected void onPreExecute() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) mProgressDialog = new ProgressDialog(MainActivity.this, android.R.style.Theme_Material_Light_Dialog_Alert); else mProgressDialog = new ProgressDialog(MainActivity.this); mProgressDialog.setTitle(R.string.processing); mProgressDialog.setMax(Constants.KEY_COUNT + 2); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setCancelable(false); mProgressDialog.show(); } @Override protected String doInBackground(Account... params) { final String sLogin = app.getAccountLogin(account); final String sPassword = app.getAccountPassword(account); final String URL = app.getAccountUrl(account); if (null == URL || null == sLogin) { return getString(R.string.error_auth); } int progress = 0; Connection connection = new Connection("tmp", sLogin, sPassword, URL); if (!connection.connect(false)) { return getString(R.string.error_sign_up); } // Setup progress dialog. mCurrentMessage = getString(R.string.look_for_city); publishProgress(progress++); connection.loadChildren(); // 1. Get city resource by key. INGWResource resource = null; for (int i = 0; i < connection.getChildrenCount(); ++i) { resource = connection.getChild(i); if (resource.getKey().equals(SettingsConstants.CITY_KEY)) { break; } resource = null; } // Check if the city is found. if (null == resource) { return getString(R.string.error_city_found); } mCurrentMessage = getString(R.string.create_base_map); publishProgress(progress++); // 2. Add background layer on map. RemoteTMSLayerUI layer = new RemoteTMSLayerUI(getApplicationContext(), mMap.createLayerStorage()); layer.setName(SettingsConstants.BASEMAP_NAME); layer.setURL(SettingsConstants.BASEMAP_URL); layer.setTMSType(GeoConstants.TMSTYPE_OSM); layer.setMaxZoom(20); layer.setMinZoom(GeoConstants.DEFAULT_MIN_ZOOM); layer.setVisible(true); layer.setCacheSizeMultiply(2); mMap.addLayer(layer); // 3. Get tables for map. mCurrentMessage = getString(R.string.start_fill_layer); publishProgress(progress++); ResourceGroup cityGroup = (ResourceGroup) resource; cityGroup.loadChildren(); Resource cityResource; for (int i = 0; i < cityGroup.getChildrenCount(); ++i) { cityResource = (Resource) cityGroup.getChild(i); if (cityResource.getKey().equals(Constants.KEY_MAIN)) { publishProgress(progress++); // Add trees layer on map. NGWVectorLayerUI ngwVectorLayer = new NGWVectorLayerUI(getApplicationContext(), mMap.createLayerStorage(cityResource.getKey())); ngwVectorLayer.setName(Constants.KEY_MAIN); ngwVectorLayer.setRemoteId(cityResource.getRemoteId()); ngwVectorLayer.setAccountName(account.name); ngwVectorLayer.setSyncType(com.nextgis.maplib.util.Constants.SYNC_ALL); ngwVectorLayer.setMinZoom(GeoConstants.DEFAULT_MIN_ZOOM); ngwVectorLayer.setMaxZoom(GeoConstants.DEFAULT_MAX_ZOOM); ngwVectorLayer.setVisible(true); // Set style based on state field. mMap.addLayer(ngwVectorLayer); try { ngwVectorLayer.createFromNGW(null); } catch (NGException | IOException | JSONException e) { mMap.delete(); e.printStackTrace(); return e.getLocalizedMessage(); } } else if (isLookupTable(cityResource)) { publishProgress(progress++); NGWLookupTable ngwTable = new NGWLookupTable(getApplicationContext(), mMap.createLayerStorage(cityResource.getKey())); ngwTable.setName(cityResource.getKey()); ngwTable.setRemoteId(cityResource.getRemoteId()); ngwTable.setAccountName(account.name); ngwTable.setSyncType(com.nextgis.maplib.util.Constants.SYNC_DATA); mMap.addLayer(ngwTable); try { ngwTable.fillFromNGW(null); } catch (NGException | IOException | JSONException e) { mMap.delete(); e.printStackTrace(); return e.getLocalizedMessage(); } } } mMap.save(); return getString(R.string.success_filled); } @Override protected void onProgressUpdate(Integer... progress) { mProgressDialog.setProgress(progress[0]); mProgressDialog.setMessage(mCurrentMessage); } @Override protected void onPostExecute(String result) { if (mProgressDialog.isShowing()) mProgressDialog.dismiss(); Toast.makeText(MainActivity.this, result, Toast.LENGTH_LONG).show(); refreshActivityView(); } } new DownloadTask().execute(account); }
From source file:com.eleybourn.bookcatalogue.utils.SimpleTaskQueueProgressFragment.java
/** * Create the underlying dialog/* w w w .j a va 2 s . c o m*/ */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { ProgressDialog dialog = new ProgressDialog(getActivity()); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(false); int msg = getArguments().getInt("title"); if (msg != 0) dialog.setMessage(getActivity().getString(msg)); final boolean isIndet = getArguments().getBoolean("isIndeterminate"); dialog.setIndeterminate(isIndet); if (isIndet) { dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); } else { dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); } // We can't use "this.requestUpdateProgress()" because getDialog() will still return null if (!isIndet) { dialog.setMax(mMax); dialog.setProgress(mProgress); if (mMessage != null) dialog.setMessage(mMessage); setDialogNumberFormat(dialog); } return dialog; }
From source file:com.markuspage.android.atimetracker.Tasks.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case ADD_TASK: return openNewTaskDialog(); case EDIT_TASK: return openEditTaskDialog(); case DELETE_TASK: return openDeleteTaskDialog(); case CHANGE_VIEW: return openChangeViewDialog(); case HELP://from ww w .jav a2 s. c o m return openAboutDialog(); case SUCCESS_DIALOG: operationSucceed = new AlertDialog.Builder(Tasks.this).setTitle(R.string.success) .setIcon(android.R.drawable.stat_notify_sdcard).setMessage(exportMessage) .setPositiveButton(android.R.string.ok, null).create(); return operationSucceed; case ERROR_DIALOG: operationFailed = new AlertDialog.Builder(Tasks.this).setTitle(R.string.failure) .setIcon(android.R.drawable.stat_notify_sdcard).setMessage(exportMessage) .setPositiveButton(android.R.string.ok, null).create(); return operationFailed; case PROGRESS_DIALOG: progressDialog = new ProgressDialog(this); progressDialog.setMessage("Copying records..."); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(false); return progressDialog; case MORE: return new AlertDialog.Builder(Tasks.this) .setItems(R.array.moreMenu, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { DBBackup backup; System.err.println("IN CLICK"); switch (which) { case 0: // CHANGE_VIEW: showDialog(CHANGE_VIEW); break; case 1: // EXPORT_VIEW: String fname = export(); perform(fname, R.string.export_csv_success, R.string.export_csv_fail); break; case 2: // COPY DB TO SD showDialog(Tasks.PROGRESS_DIALOG); if (new File(dbBackup).exists()) { // Find the database SQLiteDatabase backupDb = SQLiteDatabase.openDatabase(dbBackup, null, SQLiteDatabase.OPEN_READWRITE); SQLiteDatabase appDb = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READONLY); backup = new DBBackup(Tasks.this, progressDialog); backup.execute(appDb, backupDb); } else { InputStream in = null; OutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(dbPath)); out = new BufferedOutputStream(new FileOutputStream(dbBackup)); for (int c = in.read(); c != -1; c = in.read()) { out.write(c); } } catch (Exception ex) { Logger.getLogger(Tasks.class.getName()).log(Level.SEVERE, null, ex); exportMessage = ex.getLocalizedMessage(); showDialog(ERROR_DIALOG); } finally { try { if (in != null) { in.close(); } } catch (IOException ignored) { } try { if (out != null) { out.close(); } } catch (IOException ignored) { } } } break; case 3: // RESTORE FROM BACKUP showDialog(Tasks.PROGRESS_DIALOG); SQLiteDatabase backupDb = SQLiteDatabase.openDatabase(dbBackup, null, SQLiteDatabase.OPEN_READONLY); SQLiteDatabase appDb = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE); backup = new DBBackup(Tasks.this, progressDialog); backup.execute(backupDb, appDb); break; case 4: // PREFERENCES Intent intent = new Intent(Tasks.this, Settings.class); startActivityForResult(intent, PREFERENCES); break; case 5: // HELP: showDialog(HELP); break; default: break; } } }).create(); } return null; }
From source file:org.thialfihar.android.apg.ui.CertifyKeyActivity.java
private void uploadKey() { // Send all information needed to service to upload key in other thread Intent intent = new Intent(this, ApgIntentService.class); intent.setAction(ApgIntentService.ACTION_UPLOAD_KEYRING); // set data uri as path to keyring intent.setData(mDataUri);/*from w w w. ja v a2 s . c om*/ // fill values for this action Bundle data = new Bundle(); Spinner keyServer = (Spinner) findViewById(R.id.sign_key_keyserver); String server = (String) keyServer.getSelectedItem(); data.putString(ApgIntentService.UPLOAD_KEY_SERVER, server); intent.putExtra(ApgIntentService.EXTRA_DATA, data); // Message is received after uploading is done in ApgService ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this, getString(R.string.progress_exporting), ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { // handle messages by standard ApgHandler first super.handleMessage(message); if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) { Toast.makeText(CertifyKeyActivity.this, R.string.key_send_success, Toast.LENGTH_SHORT).show(); setResult(RESULT_OK); finish(); } } }; // Create a new Messenger for the communication back Messenger messenger = new Messenger(saveHandler); intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger); // show progress dialog saveHandler.showProgressDialog(this); // start service with intent startService(intent); }
From source file:org.thialfihar.android.apg.ui.ImportKeysActivity.java
/** * Import keys with mImportData/*from w ww. j ava2s .c om*/ */ public void importKeys() { // Message is received after importing is done in ApgService ApgIntentServiceHandler mSaveHandler = new ApgIntentServiceHandler(this, getString(R.string.progress_importing), ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { // handle messages by standard ApgIntentServiceHandler first super.handleMessage(message); if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) { // get returned data bundle Bundle returnData = message.getData(); int added = returnData.getInt(ApgIntentService.RESULT_IMPORT_ADDED); int updated = returnData.getInt(ApgIntentService.RESULT_IMPORT_UPDATED); int bad = returnData.getInt(ApgIntentService.RESULT_IMPORT_BAD); String toastMessage; if (added > 0 && updated > 0) { String addedStr = getResources().getQuantityString(R.plurals.keys_added_and_updated_1, added, added); String updatedStr = getResources().getQuantityString(R.plurals.keys_added_and_updated_2, updated, updated); toastMessage = addedStr + updatedStr; } else if (added > 0) { toastMessage = getResources().getQuantityString(R.plurals.keys_added, added, added); } else if (updated > 0) { toastMessage = getResources().getQuantityString(R.plurals.keys_updated, updated, updated); } else { toastMessage = getString(R.string.no_keys_added_or_updated); } AppMsg.makeText(ImportKeysActivity.this, toastMessage, AppMsg.STYLE_INFO).show(); if (bad > 0) { BadImportKeyDialogFragment badImportKeyDialogFragment = BadImportKeyDialogFragment .newInstance(bad); badImportKeyDialogFragment.show(getSupportFragmentManager(), "badKeyDialog"); } } } }; if (mListFragment.getKeyBytes() != null || mListFragment.getDataUri() != null) { Log.d(Constants.TAG, "importKeys started"); // Send all information needed to service to import key in other thread Intent intent = new Intent(this, ApgIntentService.class); intent.setAction(ApgIntentService.ACTION_IMPORT_KEYRING); // fill values for this action Bundle data = new Bundle(); // get selected key entries ArrayList<ImportKeysListEntry> selectedEntries = mListFragment.getSelectedData(); data.putParcelableArrayList(ApgIntentService.IMPORT_KEY_LIST, selectedEntries); intent.putExtra(ApgIntentService.EXTRA_DATA, data); // Create a new Messenger for the communication back Messenger messenger = new Messenger(mSaveHandler); intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger); // show progress dialog mSaveHandler.showProgressDialog(this); // start service with intent startService(intent); } else if (mListFragment.getServerQuery() != null) { // Send all information needed to service to query keys in other thread Intent intent = new Intent(this, ApgIntentService.class); intent.setAction(ApgIntentService.ACTION_DOWNLOAD_AND_IMPORT_KEYS); // fill values for this action Bundle data = new Bundle(); data.putString(ApgIntentService.DOWNLOAD_KEY_SERVER, mListFragment.getKeyServer()); // get selected key entries ArrayList<ImportKeysListEntry> selectedEntries = mListFragment.getSelectedData(); data.putParcelableArrayList(ApgIntentService.DOWNLOAD_KEY_LIST, selectedEntries); intent.putExtra(ApgIntentService.EXTRA_DATA, data); // Create a new Messenger for the communication back Messenger messenger = new Messenger(mSaveHandler); intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger); // show progress dialog mSaveHandler.showProgressDialog(this); // start service with intent startService(intent); } else { AppMsg.makeText(this, R.string.error_nothing_import, AppMsg.STYLE_ALERT).show(); } }
From source file:nf.frex.android.FrexActivity.java
private void setWallpaper() { final WallpaperManager wallpaperManager = WallpaperManager.getInstance(FrexActivity.this); final int desiredWidth = wallpaperManager.getDesiredMinimumWidth(); final int desiredHeight = wallpaperManager.getDesiredMinimumHeight(); final Image image = view.getImage(); final int imageWidth = image.getWidth(); final int imageHeight = image.getHeight(); final boolean useDesiredSize = desiredWidth > imageWidth || desiredHeight > imageHeight; DialogInterface.OnClickListener noListener = new DialogInterface.OnClickListener() { @Override//from ww w.j a v a 2 s. c o m public void onClick(DialogInterface dialog, int which) { // ok } }; if (useDesiredSize) { showYesNoDialog(this, R.string.set_wallpaper, getString(R.string.wallpaper_compute_msg, desiredWidth, desiredHeight), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Image wallpaperImage; try { wallpaperImage = new Image(desiredWidth, desiredHeight); } catch (OutOfMemoryError e) { alert(getString(R.string.out_of_memory)); return; } final ProgressDialog progressDialog = new ProgressDialog(FrexActivity.this); Generator.ProgressListener progressListener = new Generator.ProgressListener() { int numLines; @Override public void onStarted(int numTasks) { } @Override public void onSomeLinesComputed(int taskId, int line1, int line2) { numLines += 1 + line2 - line1; progressDialog.setProgress(numLines); } @Override public void onStopped(boolean cancelled) { progressDialog.dismiss(); if (!cancelled) { setWallpaper(wallpaperManager, wallpaperImage); } } }; final Generator wallpaperGenerator = new Generator(view.getGeneratorConfig(), SettingsActivity.NUM_CORES, progressListener); DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } wallpaperGenerator.cancel(); } }; progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(true); progressDialog.setMax(desiredHeight); progressDialog.setOnCancelListener(cancelListener); progressDialog.show(); Arrays.fill(wallpaperImage.getValues(), FractalView.MISSING_VALUE); wallpaperGenerator.start(wallpaperImage, false); } }, noListener, null); } else { showYesNoDialog(this, R.string.set_wallpaper, getString(R.string.wallpaper_replace_msg), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setWallpaper(wallpaperManager, image); } }, noListener, null); } }
From source file:com.zia.freshdocs.widget.CMISAdapter.java
protected void startProgressDlg(boolean indeterminate) { Context context = getContext(); Resources res = context.getResources(); if (_progressDlg == null || !_progressDlg.isShowing()) { _progressDlg = new ProgressDialog(context); _progressDlg.setProgressStyle(// w w w .j ava 2 s. co m indeterminate ? ProgressDialog.STYLE_SPINNER : ProgressDialog.STYLE_HORIZONTAL); _progressDlg.setMessage(res.getString(R.string.loading)); _progressDlg.setTitle(""); _progressDlg.setCancelable(true); _progressDlg.setIndeterminate(indeterminate); _progressDlg.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { interrupt(); } }); _progressDlg.show(); } }
From source file:com.xperia64.timidityae.FileBrowserFragment.java
public void saveWavPart2(final int position, final String finalval, final String needToRename) { ((TimidityActivity) getActivity()).writeFile(path.get(position), finalval); final ProgressDialog prog; prog = new ProgressDialog(getActivity()); prog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override//from w w w . j av a2 s . co m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); prog.setTitle("Converting to WAV"); prog.setMessage("Converting..."); prog.setIndeterminate(false); prog.setCancelable(false); prog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); prog.show(); new Thread(new Runnable() { @Override public void run() { while (!localfinished && prog.isShowing()) { prog.setMax(JNIHandler.maxTime); prog.setProgress(JNIHandler.currTime); try { Thread.sleep(25); } catch (InterruptedException e) { } } if (!localfinished) { JNIHandler.stop(); getActivity().runOnUiThread(new Runnable() { public void run() { Toast.makeText(getActivity(), "Conversion canceled", Toast.LENGTH_SHORT).show(); if (!Globals.keepWav) { if (new File(finalval).exists()) new File(finalval).delete(); } else { getDir(currPath); } } }); } else { getActivity().runOnUiThread(new Runnable() { public void run() { String trueName = finalval; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null && needToRename != null) { if (Globals.renameDocumentFile(getActivity(), finalval, needToRename)) { trueName = needToRename; } else { trueName = "Error"; } } Toast.makeText(getActivity(), "Wrote " + trueName, Toast.LENGTH_SHORT).show(); prog.dismiss(); getDir(currPath); } }); } } }).start(); }
From source file:uk.co.armedpineapple.cth.SDLActivity.java
private void installFiles(final SharedPreferences preferences) { final ProgressDialog dialog = new ProgressDialog(this); final UnzipTask unzipTask = new UnzipTask(app.configuration.getCthPath() + "/scripts/", this) { @Override/* w ww . j av a 2 s . co m*/ protected void onPreExecute() { super.onPreExecute(); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setMessage(getString(R.string.preparing_game_files_dialog)); dialog.setIndeterminate(false); dialog.setCancelable(false); dialog.show(); } @Override protected void onProgressUpdate(Integer... values) { super.onProgressUpdate(values); dialog.setProgress(values[0]); dialog.setMax(values[1]); } @Override protected void onPostExecute(AsyncTaskResult<String> result) { super.onPostExecute(result); Exception error; if ((error = result.getError()) != null) { Log.d(LOG_TAG, "Error copying files."); BugSenseHandler.sendException(error); } Editor edit = preferences.edit(); edit.putBoolean("scripts_copied", true); edit.putInt("last_version", currentVersion); edit.commit(); dialog.hide(); loadApplication(); } }; AsyncTask<String, Void, AsyncTaskResult<File>> copyTask = new AsyncTask<String, Void, AsyncTaskResult<File>>() { @Override protected AsyncTaskResult<File> doInBackground(String... params) { try { Files.copyAsset(SDLActivity.this, params[0], params[1]); } catch (IOException e) { return new AsyncTaskResult<File>(e); } return new AsyncTaskResult<File>(new File(params[1] + "/" + params[0])); } @Override protected void onPostExecute(AsyncTaskResult<File> result) { super.onPostExecute(result); File f; if ((f = result.getResult()) != null) { unzipTask.execute(f); } else { BugSenseHandler.sendException(result.getError()); } } }; if (Files.canAccessExternalStorage()) { copyTask.execute(ENGINE_ZIP_FILE, getExternalCacheDir().getAbsolutePath()); } else { DialogFactory.createExternalStorageWarningDialog(this, true).show(); } }