Example #1
0
  @Override
  protected Dialog onCreateDialog(int id) {
    Resources res = getResources();
    String reader = "";
    int ctr = 0;
    try {
      File f = new File(sdcardBaseDir + externalPath + csvFileName);
      BufferedReader in = new BufferedReader(new FileReader(f));
      while ((reader = in.readLine()) != null) {
        ctr++;
      }
      setTotalRecord(ctr);
    } catch (Exception e) {
      e.getMessage();
    }

    switch (id) {
      case DIALOG_DOWNLOAD_PROGRESS:
        mProgressDialog = new ProgressDialog(this);
        // mProgressDialog.setProgressDrawable(res.getDrawable(R.drawable.initialize_progress_bar_states));
        mProgressDialog.setMessage("Initializing...");
        mProgressDialog.setMax(ctr);
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();
        return mProgressDialog;
      default:
        return null;
    }
  }
 private void configuraProgressDialog(Activity context) {
   progressDialog = new ProgressDialog(context);
   progressDialog.setCancelable(true);
   progressDialog.setMax(4);
   progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
   progressDialog.setTitle(R.string.janusmob_progresso_titulo);
 }
  public static File downLoad(String path, String savedPath, ProgressDialog pd) throws Exception {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
      URL url = new URL(path);
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("GET");
      conn.setConnectTimeout(5000);

      int code = conn.getResponseCode();
      if (code == 200) {
        pd.setMax(conn.getContentLength());

        File file = new File(savedPath);
        FileOutputStream fos = new FileOutputStream(file);
        InputStream is = conn.getInputStream();
        byte[] buffer = new byte[1024];
        int len = 0;
        int total = 0;
        while ((len = is.read(buffer)) != -1) {
          fos.write(buffer, 0, len);
          total += len;
          pd.setProgress(total);
        }
        is.close();
        fos.close();
        return file;

      } else {
        return null;
      }

    } else {
      throw new IllegalAccessException("sd card is not available now");
    }
  }
 @Override
 protected void onPreExecute() {
   progressDialog = new ProgressDialog(this.context);
   progressDialog.setMessage("正在上传照片,请稍候...");
   progressDialog.setIndeterminate(false);
   progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
   progressDialog.setCanceledOnTouchOutside(false);
   progressDialog.setCancelable(true);
   progressDialog.setOnCancelListener(
       new DialogInterface.OnCancelListener() {
         @Override
         public void onCancel(DialogInterface dialogInterface) {
           alertUser();
         }
       });
   progressDialog.setButton(
       DialogInterface.BUTTON_POSITIVE,
       "取消",
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialogInterface, int i) {
           alertUser();
         }
       });
   progressDialog.setMax(total);
   progressDialog.show();
 }
        @Override
        public void handleMessage(Message msg) {

          if (mError == true) {
            return;
          }
          int max = msg.getData().getInt("max");
          int total = msg.getData().getInt("counter");
          int message = msg.getData().getInt("message");

          if (max > 0) {
            mProgressDialog.setMax(max);
            // mLogHelper.deleteTableLog();
            // fillData();
            return;
          }
          if (message == 1) {
            mProgressDialog.setMessage(getResources().getString(R.string.downloading));
          } else if (message == 2) {
            mProgressDialog.setMessage(getResources().getString(R.string.extracting));
          }

          mProgressDialog.setProgress(total);
          if (total == -2) { // ERROR downloading template
            mProgressDialog.dismiss();
            mError = true;
            showErrorDownloadMessage();
          } else if (total == -1) {
            mProgressDialog.dismiss();
            finalizeGetIndexingTemplate();
          }
        }
Example #6
0
 public static File getFileFromServer(String path, ProgressDialog pd) throws Exception {
   // 如果相等的话表示当前的sdcard挂载在手机上并且是可用的
   if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
     URL url = new URL(path);
     HttpURLConnection conn = (HttpURLConnection) url.openConnection();
     conn.setConnectTimeout(5000);
     // 获取到文件的大小
     pd.setMax(conn.getContentLength());
     InputStream is = conn.getInputStream();
     File file = new File(Environment.getExternalStorageDirectory(), "updata.apk");
     FileOutputStream fos = new FileOutputStream(file);
     BufferedInputStream bis = new BufferedInputStream(is);
     byte[] buffer = new byte[1024];
     int len;
     int total = 0;
     while ((len = bis.read(buffer)) != -1) {
       fos.write(buffer, 0, len);
       total += len;
       // 获取当前下载量
       pd.setProgress(total);
     }
     fos.close();
     bis.close();
     is.close();
     return file;
   } else {
     return null;
   }
 }
  @SuppressLint("DefaultLocale")
  private void loadApps(ProgressDialog dialog) {

    appList.clear();
    permUsage.clear();
    sharedUsers.clear();
    pkgSharedUsers.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);

      String[] perms = pkgInfo.requestedPermissions;
      if (perms != null)
        for (String perm : perms) {
          Set<String> permUsers = permUsage.get(perm);
          if (permUsers == null) {
            permUsers = new TreeSet<String>();
            permUsage.put(perm, permUsers);
          }
          permUsers.add(pkgInfo.packageName);
        }

      if (pkgInfo.sharedUserId != null) {
        Set<String> sharedUserPackages = sharedUsers.get(pkgInfo.sharedUserId);
        if (sharedUserPackages == null) {
          sharedUserPackages = new TreeSet<String>();
          sharedUsers.put(pkgInfo.sharedUserId, sharedUserPackages);
        }
        sharedUserPackages.add(pkgInfo.packageName);

        pkgSharedUsers.put(pkgInfo.packageName, pkgInfo.sharedUserId);
      }
    }

    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());
            }
          }
        });
  }
  @Override
  protected void onPreExecute() {
    progressBar = new ProgressDialog(activity);
    progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressBar.setProgress(0);
    progressBar.setMax(100);
    progressBar.setTitle("Please wait while contacting server ...");
    progressBar.show();

    t =
        new Thread(
            new Runnable() {
              int progressBarStatus = 0;

              public void run() {
                try {
                  while (true) {
                    Thread.sleep(100);

                    progressBarbHandler.post(
                        new Runnable() {
                          public void run() {
                            progressBar.setProgress(progressBarStatus);
                          }
                        });

                    progressBarStatus = (progressBarStatus + 5) % 100;
                  }
                } catch (InterruptedException e) {
                }
              }
            });

    t.start();
  }
 /**
  * Sets the progress dialog value.
  *
  * @param value the dialog value
  */
 public void setProgressDialogValue(int value) {
   if (progressDialog != null) {
     progressDialog.setIndeterminate(false);
     progressDialog.setProgress(value);
     progressDialog.setMax(100);
   }
 }
Example #10
0
  private void init() {

    progressValue = 0;
    progressBarStatus = 0;
    progressDialog = new ProgressDialog(this);
    progressDialog.setCancelable(false);
    progressDialog.setMessage("Loading Closest Location");
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setMax(100);

    Intent intent = getIntent();
    color = intent.getStringExtra(COLORMESSAGE);
    current_location =
        (LocationService.customLocation) intent.getSerializableExtra(SAVED_CURRENT_LOCATION);

    tvTrainLine = (TextView) findViewById(R.id.tv_search_criteria_info);
    setColorTVText();

    /* Color Spinner */
    colorSpinner = (Spinner) findViewById(R.id.color_spinner);
    arrayAdapter = new CustomAdapterSpinner(this, android.R.layout.simple_spinner_dropdown_item);
    colorSpinner.setAdapter(arrayAdapter);
    colorSpinner.setOnItemSelectedListener(this);

    httpRequested = false;

    setUpMapIfNeeded();
  }
Example #11
0
  @Test
  public void shouldSetMax() {
    assertThat(dialog.getMax()).isEqualTo(0);

    dialog.setMax(41);
    assertThat(dialog.getMax()).isEqualTo(41);
  }
  @Override
  protected void onPreExecute() {
    progressDialog.setTitle(titleId);
    progressDialog.setMessage(activity.getString(messageId));
    progressDialog.setIndeterminate(false);
    progressDialog.setCancelable(true);
    progressDialog.setOnCancelListener(
        new DialogInterface.OnCancelListener() {
          @Override
          public void onCancel(DialogInterface dialog) {
            ProgressingTask.this.cancel(false);
          }
        });
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setProgress(0);
    progressDialog.setMax(100);
    // progressDialog.setProgressNumberFormat(null); // requires API level 11 (Android 3.0.x)
    progressDialog.show();

    progress =
        new Progress() {
          @Override
          public boolean isCancelled() {
            return ProgressingTask.this.isCancelled();
          }

          @Override
          public void publishProgress(int value) {
            ProgressingTask.this.publishProgress(value);
          }
        };
  }
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case IMPORT_STEP_READ_FILE:
            case IMPORT_STEP_READ_WPT_FILE:
            case IMPORT_STEP_STORE_CACHES:
              parseDialog.setMessage(res.getString(msg.arg1));
              parseDialog.setMax(msg.arg2);
              parseDialog.setProgress(0);
              break;

            case IMPORT_STEP_FINISHED:
              parseDialog.dismiss();
              fromActivity.helpDialog(
                  res.getString(R.string.gpx_import_title_caches_imported),
                  msg.arg1 + " " + res.getString(R.string.gpx_import_caches_imported));
              closeActivity();
              break;

            case IMPORT_STEP_FINISHED_WITH_ERROR:
              parseDialog.dismiss();
              fromActivity.helpDialog(
                  res.getString(R.string.gpx_import_title_caches_import_failed),
                  res.getString(msg.arg1) + "\n\n" + msg.obj);
              closeActivity();
              break;
          }
        }
Example #14
0
 private void buildProgress() {
   mProgressDialog = new ProgressDialog(this);
   mProgressDialog.setMessage("A message");
   mProgressDialog.setIndeterminate(false);
   mProgressDialog.setMax(100);
   mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
 }
  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 #16
0
 protected void onPreExecute() {
   bar1 = new ProgressDialog(context);
   bar1.setTitle("Download in progress ...");
   bar1.setMax(10);
   bar1.setProgress(0);
   bar1.setProgressStyle(ProgressDialog.STYLE_SPINNER);
   bar1.show();
 }
 @Override
 protected void onProgressUpdate(Integer... progress) {
   super.onProgressUpdate(progress);
   // if we get here, length is known, now set indeterminate to false
   mProgressDialog.setIndeterminate(false);
   mProgressDialog.setMax(100);
   mProgressDialog.setProgress(progress[0]);
 }
 @Override
 protected void onPreExecute() {
   this.dialog.setMessage("Prayer Time");
   this.dialog.show();
   dialog.setIndeterminate(true);
   dialog.show();
   dialog.setMax(120);
   super.onPreExecute();
 }
Example #19
0
  public static void ShowProgress(Context ctx, String title, String message) {
    if (ctx != null) {
      pd = new ProgressDialog(ctx, ProgressDialog.STYLE_HORIZONTAL);
      pd.setMax(100);
      pd.setIndeterminate(true);

      pd = ProgressDialog.show(ctx, title, message, true, true);
    }
  }
 @Override
 protected void onPreExecute() {
   progressDialog = new ProgressDialog(context);
   progressDialog.setTitle("Download carregando...");
   progressDialog.setMax(10);
   progressDialog.setProgress(0);
   progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
   progressDialog.show();
 }
    @Override
    protected void onPreExecute() {

      super.onPreExecute();
      progressBar = new ProgressDialog(SharedDataUsingFOSAndFIS.this);
      progressBar.setMax(100);
      progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
      progressBar.show();
    }
Example #22
0
 protected void onPreExecute() {
   // Show progressDialog
   pd = new ProgressDialog(mContext);
   pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
   pd.setTitle(mContext.getResources().getString(R.string.registerTitle));
   pd.setMessage(mContext.getResources().getString(R.string.registerMessage));
   pd.setMax(100);
   pd.show();
 }
Example #23
0
 @Override
 protected void onProgressUpdate(Integer... values) {
   super.onProgressUpdate(values);
   Log.d("gagagagagaga", "" + values[0]);
   if (progressDialog != null) {
     progressDialog.setProgress(values[0]);
     progressDialog.setMax(files.length);
   }
 }
  /**
   * Attaches the activity to the ASync task.
   *
   * @param activity The activity to which results will be sent on completion of this task.
   */
  public void attachToActivity(PuzzleFragmentActivity activity) {
    if (activity.equals(this.mActivity) && mProgressDialog != null && mProgressDialog.isShowing()) {
      // The activity is already attached to this task.
      return;
    }

    if (DEBUG_GRID_GAME_FILE_CONVERTER) {
      Log.i(TAG, "Attach to activity");
    }

    // Remember the activity that started this task.
    this.mActivity = activity;

    int maxProgressCounter = 0;

    // Determine how much (old) game files and preview files have to be
    // deleted.
    mGameFilesToBeDeleted = getGameFilesToBeDeleted();
    maxProgressCounter += (mGameFilesToBeDeleted == null ? 0 : mGameFilesToBeDeleted.length);

    // Determine how much usage log files have to be deleted.
    mUsageLogFilesToBeDeleted = getUsageLogFilesToBeDeleted();
    maxProgressCounter +=
        (mUsageLogFilesToBeDeleted == null ? 0 : mUsageLogFilesToBeDeleted.length);

    // Determine how many solving attempts in the database have to be
    // converted.
    if ((solvingAttemptIds = new SolvingAttemptDatabaseAdapter().getAllToBeConverted()) != null) {
      maxProgressCounter += solvingAttemptIds.size();
    }

    if (maxProgressCounter > 0) {
      // Build the dialog
      mProgressDialog = new ProgressDialog(mActivity);
      mProgressDialog.setTitle(R.string.dialog_converting_saved_games_title);
      mProgressDialog.setMessage(
          mActivity
              .getResources()
              .getString(
                  (mCurrentVersion < 369
                      ? R.string.dialog_converting_cleanup_v1_message
                      : R.string.dialog_converting_saved_games_message)));
      mProgressDialog.setIcon(android.R.drawable.ic_dialog_info);
      mProgressDialog.setIndeterminate(false);
      mProgressDialog.setCancelable(false);
      mProgressDialog.setMax(maxProgressCounter);

      // Set style of dialog.
      mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

      // Show the dialog
      mProgressDialog.show();
    }

    // Initialize conversion results.
    mGridDefinitions = new ArrayList<String>();
  }
Example #25
0
 @Override
 public void update(int total, int len, int threadid) {
   if (flag) {
     mProgressDialog.setMax(total);
     flag = false;
   }
   progressValue += len;
   mProgressDialog.setProgress(progressValue);
 }
Example #26
0
  private static void creerProgressDialog() {
    mProgressDialog = new ProgressDialog(AppData.currentContext);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setTitle(AppData.currentContext.getString(R.string.loading));
    mProgressDialog.setMessage(AppData.currentContext.getString(R.string.startLoading));

    mProgressDialog.setMax(100);
    mProgressDialog.setProgress(0);
    mProgressDialog.setCancelable(false);
  }
Example #27
0
 private void showProgressDialog(Integer max, Integer curr) {
   pd = new ProgressDialog(activity);
   pd.setTitle("AsyncTask");
   pd.setMessage("In progress");
   pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
   pd.setMax(max);
   pd.setIndeterminate(false);
   pd.setProgress(currentProggress);
   pd.show();
 }
Example #28
0
 @Override
 protected void onPreExecute() {
   super.onPreExecute();
   progressDialog.setMax(100);
   progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
   progressDialog.setMessage("Processing scan...");
   progressDialog.setIndeterminate(false);
   progressDialog.show();
   // do initialization of required objects objects here
 }
  public void showProgressDownload(String message) {

    downloadCurrentState.setProgress(0);
    downloadCurrentState.setSecondaryProgress(50);
    downloadCurrentState.setMax(100);
    downloadCurrentState.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    downloadCurrentState.setMessage(message);
    downloadCurrentState.setCancelable(false);
    downloadCurrentState.show();
  }
  private void createDownloadProgressDialog() {
    mProgressDialog = new ProgressDialog(getActivity());
    mProgressDialog.setTitle(R.string.library_please_wait);
    mProgressDialog.setMessage(getText(R.string.library_download));
    mProgressDialog.setMax(100);
    mProgressDialog.setProgress(0);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setCancelable(false);

    mProgressDialog.show();
  }