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.saulcintero.moveon.fragments.History.java
private void ShowProgress(Context ctx, String title, String message) { if (ctx != null) { pd = new ProgressDialog(ctx, ProgressDialog.STYLE_HORIZONTAL); pd.setMax(100);//from www .j a va 2 s. c o m pd.setIndeterminate(true); pd = ProgressDialog.show(ctx, title, message, true, false); } }
From source file:com.oakesville.mythling.MediaActivity.java
private void startFrontendPlayback(Item item, final FrontendPlayer player) { if (item.isLiveTv()) { new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(item.getTitle()) .setMessage(getString(R.string.todo_frontend_live_tv)) .setPositiveButton(getString(R.string.ok), null).show(); } else {//w ww. j a va2 s . c o m try { player.play(); // reset progress count = 0; // prepare for a progress bar dialog countdownDialog = new ProgressDialog(this); countdownDialog.setCancelable(true); String msg = getString(R.string.playing) + " " + item.getTitle(); if (item.getListSubText() != null) msg += "\n" + item.getListSubText(); countdownDialog.setMessage(msg); countdownDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); countdownDialog.setProgressPercentFormat(null); countdownDialog.setProgressNumberFormat(null); countdownDialog.setMax(10); countdownDialog.setCancelable(true); countdownDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); stopTimer(); } }); countdownDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.stop), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { player.stop(); dialog.dismiss(); stopTimer(); } }); countdownDialog.setCanceledOnTouchOutside(true); countdownDialog.show(); countdownDialog.setProgress(10); tick(); } catch (Exception ex) { Log.e(TAG, ex.getMessage(), ex); if (getAppSettings().isErrorReportingEnabled()) new Reporter(ex).send(); stopTimer(); } } }
From source file:cgeo.geocaching.CacheListActivity.java
private void refreshStoredInternal(final List<Geocache> caches, final Set<Integer> additionalListIds) { detailProgress.set(0);//from ww w. jav a2 s .c om showProgress(false); final int etaTime = detailTotal * 25 / 60; final String message; if (etaTime < 1) { message = res.getString(R.string.caches_downloading) + " " + res.getString(R.string.caches_eta_ltm); } else { message = res.getString(R.string.caches_downloading) + " " + res.getQuantityString(R.plurals.caches_eta_mins, etaTime, etaTime); } final LoadDetailsHandler loadDetailsHandler = new LoadDetailsHandler(this); progress.show(this, null, message, ProgressDialog.STYLE_HORIZONTAL, loadDetailsHandler.disposeMessage()); progress.setMaxProgressAndReset(detailTotal); detailProgressTime = System.currentTimeMillis(); loadDetails(loadDetailsHandler, caches, additionalListIds); }
From source file:com.xperia64.timidityae.TimidityActivity.java
public void saveWavPart2(final String finalval, final String needToRename) { Intent new_intent = new Intent(); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 15); new_intent.putExtra(getResources().getString(R.string.msrv_outfile), finalval); sendBroadcast(new_intent); final ProgressDialog prog; prog = new ProgressDialog(TimidityActivity.this); prog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override//from w w w .j a va2 s. c om 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(); TimidityActivity.this.runOnUiThread(new Runnable() { public void run() { Toast.makeText(TimidityActivity.this, "Conversion canceled", Toast.LENGTH_SHORT).show(); if (!Globals.keepWav) { if (new File(finalval).exists()) new File(finalval).delete(); } else { fileFrag.getDir(fileFrag.currPath); } } }); } else { TimidityActivity.this.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(TimidityActivity.this, finalval, needToRename)) { trueName = needToRename; } else { trueName = "Error"; } } Toast.makeText(TimidityActivity.this, "Wrote " + trueName, Toast.LENGTH_SHORT).show(); prog.dismiss(); fileFrag.getDir(fileFrag.currPath); } }); } } }).start(); }
From source file:com.ywesee.amiko.MainActivity.java
/** * Downloads and updates the SQLite database and the error report file */// w ww .j av a2 s.co m public void downloadUpdates() { // Signal that update is in progress mUpdateInProgress = true; mDownloadedFileCount = 0; // First check network connection ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); // Fetch data... if (networkInfo != null && networkInfo.isConnected()) { // File URIs Uri databaseUri = Uri.parse("http://pillbox.oddb.org/" + Constants.appZippedDatabase()); Uri reportUri = Uri.parse("http://pillbox.oddb.org/" + Constants.appReportFile()); Uri interactionsUri = Uri.parse("http://pillbox.oddb.org/" + Constants.appZippedInteractionsFile()); // NOTE: the default download destination is a shared volume where the system might delete your file if // it needs to reclaim space for system use DownloadManager.Request requestDatabase = new DownloadManager.Request(databaseUri); DownloadManager.Request requestReport = new DownloadManager.Request(reportUri); DownloadManager.Request requestInteractions = new DownloadManager.Request(interactionsUri); // Allow download only over WIFI and Mobile network requestDatabase.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE); requestReport.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE); requestInteractions.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE); // Download visible and shows in notifications while in progress and after completion requestDatabase.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); requestReport.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); requestInteractions .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); // Set the title of this download, to be displayed in notifications (if enabled). requestDatabase.setTitle("AmiKo SQLite database update"); requestReport.setTitle("AmiKo report update"); requestInteractions.setTitle("AmiKo drug interactions update"); // Set a description of this download, to be displayed in notifications (if enabled) requestDatabase.setDescription("Updating the AmiKo database."); requestReport.setDescription("Updating the AmiKo error report."); requestInteractions.setDescription("Updating the AmiKo drug interactions."); // Set local destination to standard directory (place where files downloaded by the user are placed) /* String main_expansion_file_path = Utilities.expansionFileDir(getPackageName()); requestDatabase.setDestinationInExternalPublicDir(main_expansion_file_path, Constants.appZippedDatabase()); */ requestDatabase.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, Constants.appZippedDatabase()); requestReport.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, Constants.appReportFile()); requestInteractions.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, Constants.appZippedInteractionsFile()); // Check if file exist on non persistent store. If yes, delete it. if (Utilities.isExternalStorageReadable() && Utilities.isExternalStorageWritable()) { Utilities.deleteFile(Constants.appZippedDatabase(), Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)); Utilities.deleteFile(Constants.appReportFile(), Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)); Utilities.deleteFile(Constants.appZippedInteractionsFile(), Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)); } // The downloadId is unique across the system. It is used to make future calls related to this download. mDatabaseId = mDownloadManager.enqueue(requestDatabase); mReportId = mDownloadManager.enqueue(requestReport); mInteractionsId = mDownloadManager.enqueue(requestInteractions); mProgressBar = new ProgressDialog(MainActivity.this); mProgressBar.setMessage("Downloading SQLite database..."); mProgressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressBar.setProgress(0); mProgressBar.setMax(100); mProgressBar.setCancelable(false); mProgressBar.show(); new Thread(new Runnable() { @Override public void run() { boolean downloading = true; while (downloading) { DownloadManager.Query q = new DownloadManager.Query(); q.setFilterById(mDatabaseId); Cursor cursor = mDownloadManager.query(q); cursor.moveToFirst(); int bytes_downloaded = cursor .getInt(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)); int bytes_total = cursor .getInt(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)); if (cursor.getInt(cursor.getColumnIndex( DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_SUCCESSFUL) { downloading = false; if (mProgressBar.isShowing()) mProgressBar.dismiss(); } final int dl_progress = (int) ((bytes_downloaded * 100l) / bytes_total); runOnUiThread(new Runnable() { @Override public void run() { mProgressBar.setProgress((int) dl_progress); } }); cursor.close(); } } }).start(); } else { // Display error report } }
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
public void pleaseWait() { mProgressDialog = new ProgressDialog(this); mProgressDialog.setMessage(getResources().getString(R.string.info_connecting_server)); mProgressDialog.setIndeterminate(true); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setCancelable(false); mProgressDialog.show();/*ww w . j ava 2 s. co m*/ }
From source file:net.nightwhistler.pageturner.fragment.ReadingFragment.java
public void performSearch(String query) { LOG.debug("Starting search for: " + query); final ProgressDialog searchProgress = new ProgressDialog(context); searchProgress.setOwnerActivity(getActivity()); searchProgress.setCancelable(true);/*from w w w . j a v a 2s. co m*/ searchProgress.setMax(100); searchProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); final int[] counter = { 0 }; //Yes, this is essentially a pointer to an int :P final SearchTextTask task = new SearchTextTask(bookView.getBook()); task.setOnPreExecute(() -> { searchProgress.setMessage(getString(R.string.search_wait)); searchProgress.show(); // Hide on-screen keyboard if it is showing InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); }); task.setOnProgressUpdate((values) -> { if (isAdded()) { LOG.debug("Found match at index=" + values[0].getIndex() + ", offset=" + values[0].getStart() + " with context " + values[0].getDisplay()); SearchResult res = values[0]; if (res.getDisplay() != null) { counter[0] = counter[0] + 1; String update = String.format(getString(R.string.search_hits), counter[0]); searchProgress.setMessage(update); } searchProgress.setProgress(bookView.getPercentageFor(res.getIndex(), res.getStart())); } }); task.setOnCancelled((result) -> { if (isAdded()) { Toast.makeText(context, R.string.search_cancelled, Toast.LENGTH_LONG).show(); } }); task.setOnPostExecute((result) -> { searchProgress.dismiss(); if (!task.isCancelled() && isAdded()) { List<SearchResult> resultList = result.getOrElse(new ArrayList<>()); if (resultList.size() > 0) { searchResults = resultList; showSearchResultDialog(resultList); } else { Toast.makeText(context, R.string.search_no_matches, Toast.LENGTH_LONG).show(); } } }); searchProgress.setOnCancelListener(dialog -> task.cancel(true)); executeTask(task, query); }
From source file:net.nightwhistler.pageturner.activity.ReadingFragment.java
@Override public void performSearch(String query) { LOG.debug("Starting search for: " + query); final ProgressDialog searchProgress = new ProgressDialog(context); searchProgress.setOwnerActivity(getActivity()); searchProgress.setCancelable(true);//from w w w. j a v a2 s . c om searchProgress.setMax(100); searchProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); final SearchTextTask task = new SearchTextTask(bookView.getBook()) { int i = 0; @Override protected void onPreExecute() { super.onPreExecute(); searchProgress.setMessage(getString(R.string.search_wait)); searchProgress.show(); // Hide on-screen keyboard if it is showing InputMethodManager imm = (InputMethodManager) context .getSystemService(Activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); } @Override protected void onProgressUpdate(SearchResult... values) { if (!isAdded()) { return; } super.onProgressUpdate(values); LOG.debug("Found match at index=" + values[0].getIndex() + ", offset=" + values[0].getStart() + " with context " + values[0].getDisplay()); SearchResult res = values[0]; if (res.getDisplay() != null) { i++; String update = String.format(getString(R.string.search_hits), i); searchProgress.setMessage(update); } searchProgress.setProgress(bookView.getPercentageFor(res.getIndex(), res.getStart())); } @Override protected void onCancelled() { if (isAdded()) { Toast.makeText(context, R.string.search_cancelled, Toast.LENGTH_LONG).show(); } } protected void onPostExecute(java.util.List<SearchResult> result) { searchProgress.dismiss(); if (!isCancelled() && isAdded()) { if (result.size() > 0) { searchResults = result; showSearchResultDialog(result); } else { Toast.makeText(context, R.string.search_no_matches, Toast.LENGTH_LONG).show(); } } }; }; searchProgress.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { task.cancel(true); } }); task.execute(query); }
From source file:com.aujur.ebookreader.activity.ReadingFragment.java
@Override public void performSearch(String query) { LOG.debug("Starting search for: " + query); final ProgressDialog searchProgress = new ProgressDialog(context); searchProgress.setOwnerActivity(getActivity()); searchProgress.setCancelable(true);/*from www. ja v a2 s . c o m*/ searchProgress.setMax(100); searchProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); final SearchTextTask task = new SearchTextTask(bookView.getBook()) { int i = 0; @Override protected void onPreExecute() { super.onPreExecute(); searchProgress.setMessage(getString(R.string.search_wait)); searchProgress.show(); // Hide on-screen keyboard if it is showing InputMethodManager imm = (InputMethodManager) context .getSystemService(Activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); } @Override protected void onProgressUpdate(SearchResult... values) { if (!isAdded()) { return; } super.onProgressUpdate(values); LOG.debug("Found match at index=" + values[0].getIndex() + ", offset=" + values[0].getStart() + " with context " + values[0].getDisplay()); SearchResult res = values[0]; if (res.getDisplay() != null) { i++; String update = String.format(getString(R.string.search_hits), i); searchProgress.setMessage(update); } searchProgress.setProgress(bookView.getPercentageFor(res.getIndex(), res.getStart())); } @Override protected void onCancelled() { if (isAdded()) { Toast.makeText(context, R.string.search_cancelled, Toast.LENGTH_LONG).show(); } } protected void onPostExecute(java.util.List<SearchResult> result) { searchProgress.dismiss(); if (!isCancelled() && isAdded()) { if (result.size() > 0) { searchResults = result; searchResultWraper.setSearchResult(searchResults); // showSearchResultDialog(result); Intent intent = new Intent(getActivity(), ReadingOptionsActivity.class); Bundle bundle = new Bundle(); bundle.putInt("SELECTED_TAB", 4); intent.putExtras(bundle); startActivity(intent); } else { Toast.makeText(context, R.string.search_no_matches, Toast.LENGTH_LONG).show(); } } }; }; searchProgress.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { task.cancel(true); } }); task.execute(query); }
From source file:edu.cmu.cylab.starslinger.view.HomeActivity.java
private Dialog xshowProgress(Activity act, Bundle args) { int maxValue = args.getInt(extra.MAX); int newValue = args.getInt(extra.PCT); String msg = args.getString(extra.RESID_MSG); MyLog.i(TAG, msg);//from ww w .j ava 2s . com if (sProg != null) { sProg = null; sProgressMsg = null; } sProg = new ProgressDialog(act); if (maxValue > 0) { sProg.setMax(maxValue); sProg.setProgress(newValue); sProg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); } else { sProg.setProgressStyle(ProgressDialog.STYLE_SPINNER); } if (!TextUtils.isEmpty(msg)) { sProg.setMessage(msg); sProgressMsg = msg; } sProg.setCancelable(true); setProgressCancelHandler(); return sProg; }