Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. new Thread(new Runnable() {
  2. @Override
  3. public void run() {
  4. for (int i = 0; i < mClipboard.size(); i++) {
  5. final int index = i;
  6. // Copy, or cut, each file or directory into the destination directory
  7. final File newFile = copy(getFile(i), dest, false);
  8. scanImage(newFile, context);
  9. context.runOnUiThread(new Runnable() {
  10. @Override
  11. public void run() {
  12. // Update the adapter and increment the progress dialog
  13. if (newFile != null) adapter.add(newFile);
  14. // Increment the progress dialog
  15. dialog.setProgress(index);
  16. }
  17. });
  18. }
  19.  
  20. context.runOnUiThread(new Runnable() {
  21. @Override
  22. public void run() {
  23. // Remove paste option from action bar
  24. context.invalidateOptionsMenu();
  25. // Clear the clipboard
  26. clear();
  27. // Close the dialog
  28. dialog.dismiss();
  29. }
  30. });
  31. }
  32. }).start();
  33.  
  34. public static final int DIALOG_DOWNLOAD_PROGRESS = 0;
  35. private ProgressDialog mProgressDialog;
  36.  
  37. @Override
  38. protected Dialog onCreateDialog(int id) {
  39. switch (id) {
  40. case DIALOG_DOWNLOAD_PROGRESS:
  41. mProgressDialog = new ProgressDialog(this);
  42. mProgressDialog.setMessage("Loading..");
  43. mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  44. mProgressDialog.setCancelable(false);
  45. mProgressDialog.show();
  46. return mProgressDialog;
  47. default:
  48. return null;
  49. }
  50. }
  51.  
  52. private class DownloadZipFileTask extends AsyncTask<String, String, String> {
  53.  
  54. @Override
  55. protected void onPreExecute() {
  56. super.onPreExecute();
  57. showDialog(DIALOG_DOWNLOAD_PROGRESS);
  58. }
  59.  
  60. @Override
  61. protected String doInBackground(String... urls) {
  62. //Your background task code here.
  63. publishProgress("" + progress);
  64. }
  65.  
  66. protected void onProgressUpdate(String... progress) {
  67. mProgressDialog.setProgress(Integer.parseInt(progress[0]));
  68. }
  69.  
  70. @Override
  71. protected void onPostExecute(String result) {
  72. dismissDialog(DIALOG_DOWNLOAD_PROGRESS);
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement