Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new Thread(new Runnable() {
- @Override
- public void run() {
- for (int i = 0; i < mClipboard.size(); i++) {
- final int index = i;
- // Copy, or cut, each file or directory into the destination directory
- final File newFile = copy(getFile(i), dest, false);
- scanImage(newFile, context);
- context.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- // Update the adapter and increment the progress dialog
- if (newFile != null) adapter.add(newFile);
- // Increment the progress dialog
- dialog.setProgress(index);
- }
- });
- }
- context.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- // Remove paste option from action bar
- context.invalidateOptionsMenu();
- // Clear the clipboard
- clear();
- // Close the dialog
- dialog.dismiss();
- }
- });
- }
- }).start();
- public static final int DIALOG_DOWNLOAD_PROGRESS = 0;
- private ProgressDialog mProgressDialog;
- @Override
- protected Dialog onCreateDialog(int id) {
- switch (id) {
- case DIALOG_DOWNLOAD_PROGRESS:
- mProgressDialog = new ProgressDialog(this);
- mProgressDialog.setMessage("Loading..");
- mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- mProgressDialog.setCancelable(false);
- mProgressDialog.show();
- return mProgressDialog;
- default:
- return null;
- }
- }
- private class DownloadZipFileTask extends AsyncTask<String, String, String> {
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- showDialog(DIALOG_DOWNLOAD_PROGRESS);
- }
- @Override
- protected String doInBackground(String... urls) {
- //Your background task code here.
- publishProgress("" + progress);
- }
- protected void onProgressUpdate(String... progress) {
- mProgressDialog.setProgress(Integer.parseInt(progress[0]));
- }
- @Override
- protected void onPostExecute(String result) {
- dismissDialog(DIALOG_DOWNLOAD_PROGRESS);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement