List of usage examples for android.app ProgressDialog setProgressStyle
public void setProgressStyle(int style)
From source file:com.einzig.ipst2.activities.MainActivity.java
/** * Wrapper function for parseEmailWork.//ww w . ja va 2s . com * <p> * Builds the progress dialog for, then calls parseEmailWork * </p> * * @see MainActivity#parseEmailWork(Account, ProgressDialog) */ private void parseEmail() { if (Looper.myLooper() == Looper.getMainLooper()) { Logger.d("IS MAIN THREAD?!"); } final Account account = getAccount(); if (account != null) { final ProgressDialog dialog = new ProgressDialog(this, ThemeHelper.getDialogTheme(this)); dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); dialog.setIndeterminate(true); dialog.setTitle(getString(R.string.searching_email)); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false); dialog.show(); new Thread() { public void run() { parseEmailWork(account, dialog); } }.start(); //getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } }
From source file:com.slownet5.pgprootexplorer.filemanager.ui.FileManagerActivity.java
private void setupRoot() { if (alreadySetup()) { afterInitSetup(true);//from ww w .j a v a 2s .c om return; } final ProgressDialog dialog = new ProgressDialog(this); dialog.setIndeterminate(true); dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); dialog.setTitle("Setting up root"); dialog.setCancelable(false); ; dialog.setMax(100); final String os = SystemUtils.getSystemArchitecture(); Log.d(TAG, "setupRoot: architecture is: " + os); class Setup extends AsyncTask<Void, Integer, Boolean> { @Override protected Boolean doInBackground(Void... params) { new File(SharedData.CRYPTO_FM_PATH).mkdirs(); String filename = SharedData.CRYPTO_FM_PATH + "/toybox"; AssetManager asset = getAssets(); try { InputStream stream = asset.open("toybox"); OutputStream out = new FileOutputStream(filename); byte[] buffer = new byte[4096]; int read; int total = 0; while ((read = stream.read(buffer)) != -1) { total += read; out.write(buffer, 0, read); } Log.d(TAG, "doInBackground: total written bytes: " + total); stream.close(); out.flush(); out.close(); } catch (IOException ex) { ex.printStackTrace(); return false; } RootUtils.initRoot(filename); return true; } @Override protected void onPreExecute() { dialog.setMessage("Please wait...."); dialog.show(); } @Override protected void onPostExecute(Boolean aBoolean) { dialog.dismiss(); if (aBoolean) { SharedPreferences.Editor prefs = getSharedPreferences(CommonConstants.COMMON_SHARED_PEREFS_NAME, Context.MODE_PRIVATE).edit(); prefs.putBoolean(CommonConstants.ROOT_TOYBOX, true); prefs.apply(); prefs.commit(); afterInitSetup(true); } else { afterInitSetup(aBoolean); } } } new Setup().execute(); }
From source file:net.gerosyab.dailylog.activity.MainActivity.java
private void importCategory() { DialogProperties properties = new DialogProperties(); properties.selection_mode = DialogConfigs.SINGLE_MODE; properties.selection_type = DialogConfigs.FILE_SELECT; properties.root = new File(DialogConfigs.DEFAULT_DIR); properties.extensions = null;/* ww w. j a va 2s .co m*/ dialog = new FilePickerDialog(MainActivity.this, properties); dialog.setDialogSelectionListener(new DialogSelectionListener() { @Override public void onSelectedFilePaths(String[] files) { ProgressDialog progressDialog = new ProgressDialog(MainActivity.this); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setTitle("Importing data [" + files[0] + "]"); progressDialog.show(); //files is the array of the paths of files selected by the Application User. try { String newCategoryUUID = UUID.randomUUID().toString(); // CSVReader reader = new CSVReader(new InputStreamReader(new FileInputStream(files[0]), "UTF-8"), '\t'); CSVReader reader = new CSVReader(new InputStreamReader(new FileInputStream(files[0]), "UTF-8"), ','); String[] nextLine; long lineNum = 0; boolean dbVersionCheck = false, categoryNameCheck = false, categoryUnitCheck = false; boolean categoryTypeCheck = false, defaultValueCheck = false, headerCheck = false; boolean isCategoryNameExists = false, rowDataCheck = false, dataCheck = false; String dbVersion = null, categoryName = null, categoryUnit = null; long categoryType = -1, defaultValue = -1; // Category category = null; List<Record> records = new ArrayList<Record>(); while ((nextLine = reader.readNext()) != null) { // nextLine[] is an array of values from the line String temp2 = ""; for (int i = 0; i < nextLine.length; i++) { temp2 += nextLine[i] + ", "; } MyLog.d("opencsv", temp2); if (lineNum == 0) { //header MyLog.d("opencsv", "nextLine.length : " + nextLine.length); for (int i = 0; i < nextLine.length; i++) { String[] split2 = nextLine[i].split(":"); MyLog.d("opencsv", "split2.length : " + split2.length); MyLog.d("opencsv", "split2[0] : " + split2[0]); if (split2[0].replaceAll("\\s+", "").equals("Version")) { if (split2[1] != null && !split2[1].equals("")) { dbVersion = split2[1]; dbVersionCheck = true; } } else if (split2[0].replaceAll("\\s+", "").equals("Name")) { if (split2[1] != null && !split2[1].equals("")) { categoryName = split2[1]; if (categoryName.length() <= Category.getMaxCategoryNameLength()) { categoryNameCheck = true; } } } else if (split2[0].replaceAll("\\s+", "").equals("Unit")) { if (split2.length == 1) { categoryUnitCheck = true; } else if (split2[1] != null && !split2[1].equals("")) { categoryUnit = split2[1]; categoryUnitCheck = true; } } else if (split2[0].replaceAll("\\s+", "").equals("Type")) { if (split2[1] != null && !split2[1].equals("")) { if (split2[1].equals("0") || split2[1].equals("1") || split2[1].equals("2")) { categoryType = Long.parseLong(split2[1]); categoryTypeCheck = true; } } } else if (split2[0].replaceAll("\\s+", "").equals("DefaultValue")) { if (split2.length == 1) { defaultValueCheck = true; } else if (split2[1] != null && !split2[1].equals("")) { if (NumberUtils.isDigits(split2[1]) && NumberUtils.isNumber(split2[1])) { defaultValue = Long.parseLong(split2[1]); MyLog.d("opencsv", "split2[1] : " + split2[1]); if (defaultValue >= 0) { defaultValueCheck = true; } } } } } if (dbVersionCheck && categoryNameCheck && categoryTypeCheck) { if (categoryType == 1) { //number if (categoryUnitCheck && defaultValueCheck) { headerCheck = true; } } else { //boolean, string headerCheck = true; } } if (!headerCheck) { break; //header parsing, data checking failed } else if (Category.isCategoryNameExists(realm, categoryName)) { isCategoryNameExists = true; break; } else { // category = new Category(categoryName, categoryUnit, Category.getLastOrderNum(realm), categoryType); } } else { //data Record record; rowDataCheck = true; if (nextLine.length != 2) { rowDataCheck = false; break; } else { record = new Record(); record.setRecordType(categoryType); DateTime dateTime = StaticData.fmtForBackup.parseDateTime(nextLine[0]); if (dateTime != null) { record.setDate(new java.sql.Date(dateTime.toDate().getTime())); } else { rowDataCheck = false; break; } if (categoryType == StaticData.RECORD_TYPE_BOOLEAN) { if (nextLine[1].equals("true")) { record.setBool(true); } else { rowDataCheck = false; break; } } else if (categoryType == StaticData.RECORD_TYPE_NUMBER) { if (NumberUtils.isNumber(nextLine[1]) && NumberUtils.isDigits(nextLine[1])) { long value = Long.parseLong(nextLine[1]); if (value > Category.getMaxValue()) { rowDataCheck = false; break; } else { record.setNumber(value); } } else { dataCheck = false; break; } } else if (categoryType == StaticData.RECORD_TYPE_MEMO) { String value = nextLine[1]; if (value.length() > Category.getMaxMemoLength()) { rowDataCheck = false; break; } else { record.setString(nextLine[1]); } } } if (record != null && rowDataCheck == true) { record.setCategoryId(newCategoryUUID); record.setRecordId(UUID.randomUUID().toString()); records.add(record); } } lineNum++; } if (!headerCheck) { Toast.makeText(context, "Data file's header context/value is not correct", Toast.LENGTH_LONG).show(); } else if (isCategoryNameExists) { Toast.makeText(context, "Category Name [" + categoryName + "] is already exists", Toast.LENGTH_LONG).show(); } else if (!rowDataCheck) { Toast.makeText(context, "Data file's record data is not correct", Toast.LENGTH_LONG).show(); } else { long newOrder = Category.getNewOrderNum(realm); realm.beginTransaction(); Category category = realm.createObject(Category.class, newCategoryUUID); category.setName(categoryName); category.setUnit(categoryUnit); category.setOrder(newOrder); category.setRecordType(categoryType); realm.insert(category); realm.insertOrUpdate(records); realm.commitTransaction(); Toast.makeText(context, "Data import [ " + categoryName + " ] is completed!!", Toast.LENGTH_LONG).show(); // refreshList(); // categoryHolderList.add(getHolderFromCategory(category)); // mDragListView.getAdapter().notifyDataSetChanged(); // mDragListView.getAdapter().notifyItemInserted((int) newOrder); // setCategoryHolderList(); // mDragListView.getAdapter().setItemList(categoryHolderList); adapter.notifyDataSetChanged(); } } catch (FileNotFoundException e) { Toast.makeText(context, "Selected file is not found", Toast.LENGTH_LONG).show(); e.printStackTrace(); } catch (IOException e) { Toast.makeText(context, "File I/O exception occured", Toast.LENGTH_LONG).show(); e.printStackTrace(); } finally { progressDialog.dismiss(); } } }); dialog.show(); }
From source file:org.ros.android.app_chooser.ExchangeActivity.java
public void uninstallApp(View view) { final ExchangeActivity activity = this; final ProgressDialog progress = ProgressDialog.show(activity, "Uninstalling App", "Uninstalling " + appSelectedDisplay + "...", true, false); progress.setProgressStyle(ProgressDialog.STYLE_SPINNER); appManager.uninstallApp(appSelected, new ServiceResponseListener<UninstallApp.Response>() { @Override/*from w ww .jav a2 s. c om*/ public void onSuccess(UninstallApp.Response message) { if (!message.uninstalled) { final String errorMessage = message.message; runOnUiThread(new Runnable() { @Override public void run() { new AlertDialog.Builder(activity).setTitle("Error on Uninstallation!") .setCancelable(false).setMessage("ERROR: " + errorMessage) .setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).create().show(); } }); } runOnUiThread(new Runnable() { @Override public void run() { progress.dismiss(); } }); } @Override public void onFailure(final RemoteException e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { new AlertDialog.Builder(activity).setTitle("Error on Uninstallation").setCancelable(false) .setMessage("Failed: cannot contact robot: " + e.toString()) .setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).create().show(); progress.dismiss(); } }); } }); }
From source file:bikebadger.RideFragment.java
public void SaveGPXFileOnNewThreadWithDialog(final String path) { final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); final File gpxFile = new File(path); pd.setMessage("Saving \"" + gpxFile.getName() + "\""); pd.setIndeterminate(true);//from w ww . ja v a 2 s . c o m pd.setCancelable(false); pd.show(); Thread mThread = new Thread() { @Override public void run() { mRideManager.ExportWaypointsTrack(); pd.dismiss(); if (mRideManager.mWaypoints != null) { getActivity().runOnUiThread(new Runnable() { public void run() { //Toast.makeText(getActivity(), "Hello", Toast.LENGTH_SHORT).show(); MyToast.Show(getActivity(), "\"" + gpxFile.getName() + "\" saved", Color.BLACK); } }); } } }; mThread.start(); }
From source file:bikebadger.RideFragment.java
public void OpenGPXFileOnNewThreadWithDialog(final String path) { final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); final File gpxFile = new File(path); pd.setMessage("Loading \"" + gpxFile.getName() + "\""); pd.setIndeterminate(true);// w w w .jav a 2 s. c o m pd.setCancelable(false); pd.show(); Thread mThread = new Thread() { @Override public void run() { mRideManager.OpenGPXFile(path); pd.dismiss(); if (mRideManager.mWaypoints != null) { getActivity().runOnUiThread(new Runnable() { public void run() { //Toast.makeText(getActivity(), "Hello", Toast.LENGTH_SHORT).show(); MyToast.Show(getActivity(), "\"" + gpxFile.getName() + "\" loaded (" + mRideManager.mWaypoints.size() + ")", Color.BLACK); } }); } } }; mThread.start(); }
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//w ww . j av a 2s . c o 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:com.yeldi.yeldibazaar.AppDetails.java
private ProgressDialog createProgressDialog(String file, int p, int max) { final ProgressDialog pd = new ProgressDialog(this); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pd.setMessage(getString(R.string.download_server) + ":\n " + file); pd.setMax(max);//w ww .j a v a 2 s.c o m pd.setProgress(p); pd.setCancelable(true); pd.setCanceledOnTouchOutside(false); pd.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { downloadHandler.cancel(); } }); pd.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { pd.cancel(); } }); pd.show(); return pd; }
From source file:com.microsoft.live.sample.skydrive.SkyDriveActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == FilePicker.PICK_FILE_REQUEST) { if (resultCode == RESULT_OK) { String filePath = data.getStringExtra(FilePicker.EXTRA_FILE_PATH); if (TextUtils.isEmpty(filePath)) { showToast("No file was choosen."); return; }/*from w w w.j a v a 2 s . c o m*/ File file = new File(filePath); final ProgressDialog uploadProgressDialog = new ProgressDialog(SkyDriveActivity.this); uploadProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); uploadProgressDialog.setMessage("Uploading..."); uploadProgressDialog.setCancelable(true); uploadProgressDialog.show(); final LiveOperation operation = mClient.uploadAsync(mCurrentFolderId, file.getName(), file, new LiveUploadOperationListener() { @Override public void onUploadProgress(int totalBytes, int bytesRemaining, LiveOperation operation) { int percentCompleted = computePrecentCompleted(totalBytes, bytesRemaining); uploadProgressDialog.setProgress(percentCompleted); } @Override public void onUploadFailed(LiveOperationException exception, LiveOperation operation) { uploadProgressDialog.dismiss(); showToast(exception.getMessage()); } @Override public void onUploadCompleted(LiveOperation operation) { uploadProgressDialog.dismiss(); JSONObject result = operation.getResult(); if (result.has(JsonKeys.ERROR)) { JSONObject error = result.optJSONObject(JsonKeys.ERROR); String message = error.optString(JsonKeys.MESSAGE); String code = error.optString(JsonKeys.CODE); showToast(code + ": " + message); return; } loadFolder(mCurrentFolderId); } }); uploadProgressDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { operation.cancel(); } }); } } }
From source file:org.namelessrom.devicecontrol.appmanager.AppDetailsActivity.java
private void uninstall() { // try via native package manager api AppHelper.uninstallPackage(mPm, mAppItem.getPackageName()); // build our command final StringBuilder sb = new StringBuilder(); sb.append(String.format("pm uninstall %s;", mAppItem.getPackageName())); if (mAppItem.isSystemApp()) { sb.append("busybox mount -o rw,remount /system;"); }/*from w ww . j a v a 2 s. c om*/ sb.append(String.format("rm -rf %s;", mAppItem.getApplicationInfo().publicSourceDir)); sb.append(String.format("rm -rf %s;", mAppItem.getApplicationInfo().sourceDir)); sb.append(String.format("rm -rf %s;", mAppItem.getApplicationInfo().dataDir)); if (mAppItem.isSystemApp()) { sb.append("busybox mount -o ro,remount /system;"); } final String cmd = sb.toString(); Logger.v(this, cmd); // create the dialog (will not be shown for a long amount of time though) final ProgressDialog dialog; dialog = new ProgressDialog(this); dialog.setTitle(R.string.uninstalling); dialog.setMessage(getString(R.string.applying_wait)); dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); dialog.setCancelable(false); new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { dialog.show(); } @Override protected Void doInBackground(Void... voids) { Utils.runRootCommand(cmd, true); return null; } @Override protected void onPostExecute(Void aVoid) { dialog.dismiss(); Toast.makeText(AppDetailsActivity.this, getString(R.string.uninstall_success, mAppItem.getLabel()), Toast.LENGTH_SHORT).show(); mAppItem = null; finish(); } }.execute(); }