Java Code Examples for android.app.progressdialog#setProgress()

The following examples show how to use android.app.progressdialog#setProgress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UploadFile.java    From BLEConnect with GNU General Public License v2.0 6 votes vote down vote up
public UploadFile(Context context, DropboxAPI<?> api, String dropboxPath,
        File file) {
    // We set the context this way so we don't accidentally leak activities
    mContext = context.getApplicationContext();

    mFileLen = file.length();
    mApi = api;
    mPath = dropboxPath;
    mFile = file;

    mDialog = new ProgressDialog(context);
    mDialog.setMax(100);
    mDialog.setMessage("Uploading " + file.getName());
    mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mDialog.setProgress(0);
    mDialog.setButton("Cancel", new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // This will cancel the putFile operation
            mRequest.abort();
        }
    });
    mDialog.show();
}
 
Example 2
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 6 votes vote down vote up
/**
 * Shows a progress dialog for the given job.
 *
 * @param job to track progress from
 */
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);
}
 
Example 3
Source File: StringAsyncTask.java    From geopaparazzi with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    if (doProgress) {
        progressDialog = new ProgressDialog(context);
        if (title == null) {
            progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        } else {
            progressDialog.setTitle(title);
        }
        progressDialog.setMessage(message);
        progressDialog.setCancelable(cancelable);
        if (max == null) {
            progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            progressDialog.setIndeterminate(true);
        } else {
            progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progressDialog.setIndeterminate(false);
            progressDialog.setProgress(0);
            progressDialog.setMax(max);
        }
        progressDialog.show();
    }
}
 
Example 4
Source File: MainActivity.java    From Android-Basics-Codes with Artistic License 2.0 6 votes vote down vote up
public void click4(View v){
	final ProgressDialog pd = new ProgressDialog(this);
	//���ý���������ʽ
	pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	//���ý��������ֵ
	pd.setMax(100);
	pd.setTitle("�����Թ��У����Ժ�");
	Thread t = new Thread(){
		@Override
		public void run() {
			try {
				for (int i = 0; i <= 100; i++) {
		pd.setProgress(i);
					sleep(50);
	}
} catch (InterruptedException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
			pd.dismiss();
		}
	};
	t.start();
	pd.show();
}
 
Example 5
Source File: NovelListActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
private void loadSearchResultList() {
	// the result is just 10 records, so don't need "isLoading"
	List<NameValuePair> targVarList = new ArrayList<NameValuePair>();
	if (plus == 1) {
		targVarList.add(Wenku8Interface.searchNovelByNovelName(name,
				GlobalConfig.getFetchLanguage()));
	} else if (plus == 2) {
		targVarList.add(Wenku8Interface.searchNovelByAuthorName(name,
				GlobalConfig.getFetchLanguage()));

	}

	isSearching = true;
	final asyncSearchTask ast = new asyncSearchTask();
	ast.execute(targVarList);

	pDialog = new ProgressDialog(parentActivity);
	pDialog.setTitle(getResources().getString(R.string.search_ing));
	pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	pDialog.setCancelable(true);
	pDialog.setOnCancelListener(new OnCancelListener() {
		@Override
		public void onCancel(DialogInterface dialog) {
			// TODO Auto-generated method stub
			isSearching = false;
			if (pDialog != null)
				pDialog.dismiss();
			pDialog = null;
		}

	});
	pDialog.setMessage(getResources().getString(R.string.search_fetching));
	pDialog.setProgress(0);
	pDialog.setMax(1);
	pDialog.show();

	return;
}
 
Example 6
Source File: Exporter.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
	dialog = new ProgressDialog(context);		
	dialog.setTitle(R.string.export_exporting);
	dialog.setIndeterminate(false);
	dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	dialog.setCancelable(false);
	dialog.setProgress(0);
	dialog.setMax(1);
	dialog.show();
}
 
Example 7
Source File: AppList.java    From CustomText with Apache License 2.0 5 votes vote down vote up
@SuppressLint("DefaultLocale")
private void loadApps(ProgressDialog dialog) {
	appList.clear();
	PackageManager pm = getPackageManager();
	List<PackageInfo> pkgs = getPackageManager().getInstalledPackages(PackageManager.GET_PERMISSIONS);
	dialog.setMax(pkgs.size());
	int i = 1;
	for (PackageInfo pkgInfo : pkgs) {
		dialog.setProgress(i++);
		ApplicationInfo appInfo = pkgInfo.applicationInfo;
		if (appInfo == null)
			continue;
		appInfo.name = appInfo.loadLabel(pm).toString();
		appList.add(appInfo);
	}

	Collections.sort(appList, new Comparator<ApplicationInfo>() {
		@Override
		public int compare(ApplicationInfo lhs, ApplicationInfo rhs) {
			if (lhs.name == null) {
				return -1;
			} else if (rhs.name == null) {
				return 1;
			} else {
				return lhs.name.toUpperCase().compareTo(rhs.name.toUpperCase());
			}
		}
	});
}
 
Example 8
Source File: LrcJaeger.java    From LrcJaeger with Apache License 2.0 5 votes vote down vote up
private void download(final ArrayList<SongItem> listAll, final LrcJaeger activity) {
    if (listAll.size() > 0) {
        final ProgressDialog progressDialog = new ProgressDialog(activity);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setTitle(activity.getString(R.string.title_downloading));
        progressDialog.setProgress(0);
        progressDialog.setMax(listAll.size());
        progressDialog.show();

        activity.mTask = new BulkDownloadTask(new BulkDownloadTask.EventListener() {
            @Override
            public void onFinish(int downloaded) {
                progressDialog.dismiss();
                sendEmptyMessage(MSG_UPDATE_LRC_ICON_ALL);

                String text = String.format(activity.getString(R.string.toast_lrc_downloaded),
                        downloaded, listAll.size());
                Toast.makeText(activity, text, Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onProgressUpdate(int progress) {
                progressDialog.setProgress(progress);
            }
        });
        activity.mTask.execute(listAll.toArray(new SongItem[1]));
    }
}
 
Example 9
Source File: ToolsDownloader.java    From Beats with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void showDownloadBar() {
	downloadBar = new ProgressDialog(this);
	downloadBar.setCancelable(false);
	downloadBar.setMessage(
			Tools.getString(R.string.ToolsDownloader_downloading) + url
			);
	downloadBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	downloadBar.setProgress(0);
	downloadBar.setOwnerActivity(this);
	downloadBar.show();
}
 
Example 10
Source File: NovelReaderActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
private void getNC() {
	List<NameValuePair> targVar = new ArrayList<NameValuePair>();
	targVar.add(Wenku8Interface.getNovelContent(currentAid, currentCid,
			GlobalConfig.getFetchLanguage()));

	final asyncNovelContentTask ast = new asyncNovelContentTask();
	ast.execute(targVar);

	pDialog = new ProgressDialog(parentActivity);
	pDialog.setTitle(getResources().getString(R.string.load_status));
	pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	pDialog.setCancelable(true);
	pDialog.setOnCancelListener(new OnCancelListener() {
		@Override
		public void onCancel(DialogInterface dialog) {
			// TODO Auto-generated method stub
			ast.cancel(true);
			pDialog.dismiss();
			pDialog = null;
		}

	});
	pDialog.setMessage(getResources().getString(R.string.load_loading));
	pDialog.setProgress(0);
	pDialog.setMax(1);
	pDialog.show();

	return;
}
 
Example 11
Source File: UpgradeAppTask.java    From SkyTube with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
	// setup the download dialog and display it
	downloadDialog = new ProgressDialog(context);
	downloadDialog.setMessage(context.getString(R.string.downloading));
	downloadDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	downloadDialog.setProgress(0);
	downloadDialog.setMax(100);
	downloadDialog.setCancelable(false);
	downloadDialog.setProgressNumberFormat(null);
	downloadDialog.show();
}
 
Example 12
Source File: GetChromium.java    From getChromium with GNU General Public License v3.0 5 votes vote down vote up
private void showProgress() {
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setTitle(getString(R.string.progress_title));
    mProgressDialog.setMessage(getString(R.string.progress_detail));
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setProgress(0);
    mProgressDialog.setProgressNumberFormat(null);
    mProgressDialog.setProgressPercentFormat(null);
    mProgressDialog.show();
}
 
Example 13
Source File: RxOkHttp.java    From NewsMe with Apache License 2.0 5 votes vote down vote up
private static UIProgressResponseListener progressResponseListener(ProgressDialog dialog) {
    return new UIProgressResponseListener() {
        @Override
        public void onUIResponseProgress(long bytesRead, long contentLength, boolean done) {
            int  progress = (int) ((100 * bytesRead) / contentLength);
            if (bytesRead <= 0) {
                dialog.show();
            }
            if (done) {
                dialog.dismiss();
            }
            dialog.setProgress(progress);
        }
    };
}
 
Example 14
Source File: OSMMapBuilder.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected static void setupProgressDialog(MapActivity mapActivity) {
        progressDialog = new ProgressDialog(mapActivity);
        progressDialog.setTitle("Loading OSM Data");
        progressDialog.setMessage("");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
//        progressDialog.setCancelable(false);
        progressDialog.setProgress(0);
        progressDialog.setMax(100);
        progressDialog.show();
    }
 
Example 15
Source File: MainActivity.java    From MVP-Architecture-Components with Apache License 2.0 5 votes vote down vote up
private ProgressDialog createProgressDialog(Context context) {
    ProgressDialog progressDialog = new ProgressDialog(context);
    progressDialog.setMessage("Loading");
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setCancelable(false);
    progressDialog.setProgress(0);
    return progressDialog;
}
 
Example 16
Source File: NovelReaderActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
private void getNC() {
	List<NameValuePair> targVar = new ArrayList<NameValuePair>();
	targVar.add(Wenku8Interface.getNovelContent(currentAid, currentCid,
			GlobalConfig.getFetchLanguage()));

	final asyncNovelContentTask ast = new asyncNovelContentTask();
	ast.execute(targVar);

	pDialog = new ProgressDialog(parentActivity);
	pDialog.setTitle(getResources().getString(R.string.load_status));
	pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	pDialog.setCancelable(true);
	pDialog.setOnCancelListener(new OnCancelListener() {
		@Override
		public void onCancel(DialogInterface dialog) {
			// TODO Auto-generated method stub
			ast.cancel(true);
			pDialog.dismiss();
			pDialog = null;
		}

	});
	pDialog.setMessage(getResources().getString(R.string.load_loading));
	pDialog.setProgress(0);
	pDialog.setMax(1);
	pDialog.show();

	return;
}
 
Example 17
Source File: PostsAdapter.java    From Hify with MIT License 5 votes vote down vote up
protected void onPreExecute(){
    mProgressDialog=new ProgressDialog(context);
    mProgressDialog.setIndeterminate(false);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setTitle("Please wait");
    mProgressDialog.setMessage("We are processing the image for sharing...");
    mProgressDialog.setCancelable(false);
    mProgressDialog.show();
    mProgressDialog.setProgress(0);
}
 
Example 18
Source File: ShutdownThread.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private static ProgressDialog showShutdownDialog(Context context) {
    // Throw up a system dialog to indicate the device is rebooting / shutting down.
    ProgressDialog pd = new ProgressDialog(context);

    // Path 1: Reboot to recovery for update
    //   Condition: mReason startswith REBOOT_RECOVERY_UPDATE
    //
    //  Path 1a: uncrypt needed
    //   Condition: if /cache/recovery/uncrypt_file exists but
    //              /cache/recovery/block.map doesn't.
    //   UI: determinate progress bar (mRebootHasProgressBar == True)
    //
    // * Path 1a is expected to be removed once the GmsCore shipped on
    //   device always calls uncrypt prior to reboot.
    //
    //  Path 1b: uncrypt already done
    //   UI: spinning circle only (no progress bar)
    //
    // Path 2: Reboot to recovery for factory reset
    //   Condition: mReason == REBOOT_RECOVERY
    //   UI: spinning circle only (no progress bar)
    //
    // Path 3: Regular reboot / shutdown
    //   Condition: Otherwise
    //   UI: spinning circle only (no progress bar)

    // mReason could be "recovery-update" or "recovery-update,quiescent".
    if (mReason != null && mReason.startsWith(PowerManager.REBOOT_RECOVERY_UPDATE)) {
        // We need the progress bar if uncrypt will be invoked during the
        // reboot, which might be time-consuming.
        mRebootHasProgressBar = RecoverySystem.UNCRYPT_PACKAGE_FILE.exists()
                && !(RecoverySystem.BLOCK_MAP_FILE.exists());
        pd.setTitle(context.getText(com.android.internal.R.string.reboot_to_update_title));
        if (mRebootHasProgressBar) {
            pd.setMax(100);
            pd.setProgress(0);
            pd.setIndeterminate(false);
            pd.setProgressNumberFormat(null);
            pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            pd.setMessage(context.getText(
                        com.android.internal.R.string.reboot_to_update_prepare));
        } else {
            if (showSysuiReboot()) {
                return null;
            }
            pd.setIndeterminate(true);
            pd.setMessage(context.getText(
                        com.android.internal.R.string.reboot_to_update_reboot));
        }
    } else if (mReason != null && mReason.equals(PowerManager.REBOOT_RECOVERY)) {
        if (RescueParty.isAttemptingFactoryReset()) {
            // We're not actually doing a factory reset yet; we're rebooting
            // to ask the user if they'd like to reset, so give them a less
            // scary dialog message.
            pd.setTitle(context.getText(com.android.internal.R.string.power_off));
            pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
            pd.setIndeterminate(true);
        } else {
            // Factory reset path. Set the dialog message accordingly.
            pd.setTitle(context.getText(com.android.internal.R.string.reboot_to_reset_title));
            pd.setMessage(context.getText(
                        com.android.internal.R.string.reboot_to_reset_message));
            pd.setIndeterminate(true);
        }
    } else {
        if (showSysuiReboot()) {
            return null;
        }
        pd.setTitle(context.getText(com.android.internal.R.string.power_off));
        pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
        pd.setIndeterminate(true);
    }
    pd.setCancelable(false);
    pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);

    pd.show();
    return pd;
}
 
Example 19
Source File: DeviceActivity.java    From SensorTag-CC2650 with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
	super.onCreate(savedInstanceState);
	Intent intent = getIntent();

	// BLE
	mBtLeService = BluetoothLeService.getInstance();
	mBluetoothDevice = intent.getParcelableExtra(EXTRA_DEVICE);
	mServiceList = new ArrayList<BluetoothGattService>();

	mIsSensorTag2 = false;
	// Determine type of SensorTagGatt
	String deviceName = mBluetoothDevice.getName();
	if ((deviceName.equals("SensorTag2")) ||(deviceName.equals("CC2650 SensorTag"))) {
		mIsSensorTag2 = true;
	}
	else mIsSensorTag2 = false;

	PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
	// Log.i(TAG, "Preferences for: " + deviceName);

	// GUI
	mDeviceView = new DeviceView();
	mSectionsPagerAdapter.addSection(mDeviceView, "Sensors");
	HelpView hw = new HelpView();
	hw.setParameters("help_device.html", R.layout.fragment_help, R.id.webpage);
	mSectionsPagerAdapter.addSection(hw, "Help");
	mProfiles = new ArrayList<GenericBluetoothProfile>();
	progressDialog = new ProgressDialog(DeviceActivity.this);
	progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	progressDialog.setIndeterminate(true);
	progressDialog.setTitle("Discovering Services");
       progressDialog.setMessage("");
	progressDialog.setMax(100);
       progressDialog.setProgress(0);
       progressDialog.show();

       // GATT database
	Resources res = getResources();
	XmlResourceParser xpp = res.getXml(R.xml.gatt_uuid);
	new GattInfo(xpp);

}
 
Example 20
Source File: FileIO.java    From Android-FileBrowser-FilePicker with MIT License 4 votes vote down vote up
public void pasteFiles(final File destination) {

        final Operations op = Operations.getInstance(mContext);
        final List<FileItem> selectedItems = op.getSelectedFiles();
        final Operations.FILE_OPERATIONS operation = op.getOperation();
        if(destination.canWrite()) {
            if (selectedItems != null && selectedItems.size() > 0) {
                final ProgressDialog progressDialog = new ProgressDialog(mContext);
                String title = mContext.getString(R.string.wait);
                progressDialog.setTitle(title);
                if (operation == Operations.FILE_OPERATIONS.COPY)
                    progressDialog.setTitle(mContext.getString(R.string.copying,title));
                else if (operation == Operations.FILE_OPERATIONS.CUT)
                    progressDialog.setTitle(mContext.getString(R.string.moving,title));

                progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                progressDialog.setCancelable(false);
                progressDialog.setMessage("");
                progressDialog.setProgress(0);
                progressDialog.show();
                executor.execute(new Runnable() {
                    @Override
                    public void run() {
                        int i = 0;
                        float TOTAL_ITEMS = selectedItems.size();
                        try {
                            for (; i < selectedItems.size(); i++) {
                                mUIUpdateHandler.post(mHelper.progressUpdater(progressDialog, (int) ((i / TOTAL_ITEMS) * 100), "File: " + selectedItems.get(i).getFile().getName()));
                                if (selectedItems.get(i).getFile().isDirectory()) {
                                    if (operation == Operations.FILE_OPERATIONS.CUT)
                                        FileUtils.moveDirectory(selectedItems.get(i).getFile(), new File(destination, selectedItems.get(i).getFile().getName()));
                                    else if (operation == Operations.FILE_OPERATIONS.COPY)
                                        FileUtils.copyDirectory(selectedItems.get(i).getFile(), new File(destination, selectedItems.get(i).getFile().getName()));
                                } else {
                                    if (operation == Operations.FILE_OPERATIONS.CUT)
                                        FileUtils.moveFile(selectedItems.get(i).getFile(), new File(destination, selectedItems.get(i).getFile().getName()));
                                    else if (operation == Operations.FILE_OPERATIONS.COPY)
                                        FileUtils.copyFile(selectedItems.get(i).getFile(), new File(destination, selectedItems.get(i).getFile().getName()));
                                }
                            }
                            mUIUpdateHandler.post(new Runnable() {
                                @Override
                                public void run() {
                                    op.resetOperation();
                                }
                            });
                            mUIUpdateHandler.post(mHelper.toggleProgressBarVisibility(progressDialog));
                            mUIUpdateHandler.post(mHelper.updateRunner());
                        } catch (IOException e) {
                            e.printStackTrace();
                            mUIUpdateHandler.post(mHelper.toggleProgressBarVisibility(progressDialog));
                            mUIUpdateHandler.post(mHelper.errorRunner(mContext.getString(R.string.pasting_error)));
                        }
                    }
                });
            } else {
                UIUtils.ShowToast(mContext.getString(R.string.no_items_selected), mContext);
            }
        } else {
            UIUtils.ShowToast(mContext.getString(R.string.permission_error),mContext);
        }
    }