Example usage for android.app ProgressDialog STYLE_SPINNER

List of usage examples for android.app ProgressDialog STYLE_SPINNER

Introduction

In this page you can find the example usage for android.app ProgressDialog STYLE_SPINNER.

Prototype

int STYLE_SPINNER

To view the source code for android.app ProgressDialog STYLE_SPINNER.

Click Source Link

Document

Creates a ProgressDialog with a circular, spinning progress bar.

Usage

From source file:study.tdcc.act.MainCalendar.java

/**
 * AccessToken????//from w  w  w. j  a v  a  2s.  c o  m
 *
 */
private void getAccessToken() {
    Log.d("DEBUG", "MainCalendar getAccessToken Start");
    //??
    pdObj = new ProgressDialog(MainCalendar.this);
    pdObj.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    pdObj.setMessage(getString(R.string.getToken));
    //?????
    pdObj.setCancelable(false);
    //?
    pdObj.show();
    //????
    Thread thread = new Thread(runGetAccessToken);
    //?
    thread.start();
    Log.d("DEBUG", "MainCalendar getAccessToken End");
}

From source file:com.Beat.RingdroidEditActivity.java

private void saveRingtone(final CharSequence title) {
    final String outPath = makeRingtoneFilename(title, mExtension);

    if (outPath == null) {
        showFinalAlert(new Exception(), R.string.no_unique_filename);
        return;//from w w w . j ava 2  s  .  c om
    }

    mDstFilename = outPath;

    double startTime = mWaveformView.pixelsToSeconds(mStartPos);
    double endTime = mWaveformView.pixelsToSeconds(mEndPos);
    final int startFrame = mWaveformView.secondsToFrames(startTime);
    final int endFrame = mWaveformView.secondsToFrames(endTime);
    final int duration = (int) (endTime - startTime + 0.5);

    // Create an indeterminate progress dialog
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setTitle(R.string.progress_dialog_saving);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setCancelable(false);
    mProgressDialog.show();

    // Save the sound file in a background thread
    new Thread() {
        public void run() {
            final File outFile = new File(outPath);
            try {
                // Write the new file
                mSoundFile.WriteFile(outFile, startFrame, endFrame - startFrame);

                // Try to load the new file to make sure it worked
                final CheapSoundFile.ProgressListener listener = new CheapSoundFile.ProgressListener() {
                    public boolean reportProgress(double frac) {
                        // Do nothing - we're not going to try to
                        // estimate when reloading a saved sound
                        // since it's usually fast, but hard to
                        // estimate anyway.
                        return true; // Keep going
                    }
                };
                CheapSoundFile.create(outPath, listener);
            } catch (Exception e) {
                mProgressDialog.dismiss();

                CharSequence errorMessage;
                if (e.getMessage().equals("No space left on device")) {
                    errorMessage = getResources().getText(R.string.no_space_error);
                    e = null;
                } else {
                    errorMessage = getResources().getText(R.string.write_error);
                }

                final CharSequence finalErrorMessage = errorMessage;
                final Exception finalException = e;
                Runnable runnable = new Runnable() {
                    public void run() {
                        handleFatalError("WriteError", finalErrorMessage, finalException);
                    }
                };
                mHandler.post(runnable);
                return;
            }

            mProgressDialog.dismiss();

            Runnable runnable = new Runnable() {
                public void run() {
                    afterSavingRingtone(title, outPath, outFile, duration);
                }
            };
            mHandler.post(runnable);
        }
    }.start();
}

From source file:com.fabernovel.alertevoirie.ReportDetailsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_PROGRESS:
        mPd = new ProgressDialog(this);
        mPd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mPd.setIndeterminate(true);//from w  w w. java 2s. c  o m
        mPd.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                removeDialog(DIALOG_PROGRESS);
            }
        });
        mPd.setOnCancelListener(new OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                AVService.getInstance(ReportDetailsActivity.this).cancelTask();
                finish();
            }
        });
        mPd.setMessage(getString(R.string.ui_message_loading));
        return mPd;

    case DIALOG_TIMEOUT:
        return new AlertDialog.Builder(getApplicationContext()).setTitle(R.string.timeout_popup_title)
                .setMessage(R.string.timeout_popup_message)
                .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                }).create();

    default:
        return super.onCreateDialog(id);
    }
}

From source file:study.tdcc.act.MainCalendar.java

/**
 * AccessToken??/*w ww .  j  a v a  2 s .  c  om*/
 *
 */
private void refreshToken() {
    Log.d("DEBUG", "MainCalendar refreshToken Start");
    //??
    pdObj = new ProgressDialog(MainCalendar.this);
    pdObj.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    pdObj.setMessage(getString(R.string.getToken));
    //?????
    pdObj.setCancelable(false);
    //?
    pdObj.show();
    //????
    Thread thread = new Thread(runRefreshToken);
    //?
    thread.start();
    Log.d("DEBUG", "MainCalendar refreshToken End");
}

From source file:study.tdcc.act.MainCalendar.java

/**
 * getGoogleCalendar ? updateGoogleCalendar??
 * ????/*  w w  w .  j  a  va  2  s  .  c o  m*/
 */
public void syncGoogleCalendar() {
    Log.d("DEBUG", "MainCalendar syncGoogleCalendar Start");
    //??
    pdObj = new ProgressDialog(MainCalendar.this);
    pdObj.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    pdObj.setMessage(getString(R.string.nowOnSync));
    //?????
    pdObj.setCancelable(false);
    //?
    pdObj.show();
    //????
    Thread thread = new Thread(runSyncGoogleCalendar);
    //?
    thread.start();
    Log.d("DEBUG", "MainCalendar syncGoogleCalendar End");
}

From source file:org.totschnig.myexpenses.activity.MyExpenses.java

@Override
public void onPositive(Bundle args) {
    switch (args.getInt(ConfirmationDialogFragment.KEY_COMMAND_POSITIVE)) {
    case R.id.START_EXPORT_COMMAND:
        mExportFormat = args.getString("format");
        args.putSparseParcelableArray(TransactionList.KEY_FILTER, getCurrentFragment().getFilterCriteria());
        getSupportFragmentManager().beginTransaction()
                .add(TaskExecutionFragment.newInstanceExport(args), ProtectionDelegate.ASYNC_TAG)
                .add(ProgressDialogFragment.newInstance(R.string.pref_category_title_export, 0,
                        ProgressDialog.STYLE_SPINNER, true), ProtectionDelegate.PROGRESS_TAG)
                .commit();// w ww.ja  v  a2 s. com
        break;
    case R.id.BALANCE_COMMAND_DO:
        startTaskExecution(TaskExecutionFragment.TASK_BALANCE, new Long[] { args.getLong(KEY_ROWID) },
                args.getBoolean("deleteP"), 0);
        break;
    case R.id.DELETE_COMMAND_DO:
        //Confirmation dialog was shown without Checkbox, because it was called with only void transactions
        onPositive(args, false);
    }
}

From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java

private void sendRegistrationRequest(final String email) {
    final ProgressDialog progressDialog = new ProgressDialog(RegistrationActivity2.this);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setMessage(getString(R.string.registration_sending_email, email));
    progressDialog.setCancelable(true);//from   w w w . j a v a 2 s .  c  o  m
    progressDialog.show();
    final SafeRunnable showErrorDialog = new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            T.UI();
            progressDialog.dismiss();
            AlertDialog.Builder builder = new AlertDialog.Builder(RegistrationActivity2.this);
            builder.setMessage(R.string.error_please_try_again);
            builder.setPositiveButton(R.string.rogerthat, null);
            AlertDialog dialog = builder.create();
            dialog.show();
        }
    };
    final String timestamp = "" + mWiz.getTimestamp();
    final String registrationId = mWiz.getRegistrationId();
    final String deviceId = mWiz.getDeviceId();

    mWorkerHandler.post(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            T.REGISTRATION();
            String version = "2";
            String requestSignature = Security.sha256(version + email + " " + timestamp + " " + deviceId + " "
                    + registrationId + " " + CloudConstants.REGISTRATION_EMAIL_SIGNATURE);

            HttpPost httppost = new HttpPost(CloudConstants.REGISTRATION_REQUEST_URL);
            try {
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(6);
                nameValuePairs.add(new BasicNameValuePair("version", version));
                nameValuePairs.add(new BasicNameValuePair("email", email));
                nameValuePairs.add(new BasicNameValuePair("registration_time", timestamp));
                nameValuePairs.add(new BasicNameValuePair("device_id", deviceId));
                nameValuePairs.add(new BasicNameValuePair("registration_id", registrationId));
                nameValuePairs.add(new BasicNameValuePair("request_signature", requestSignature));
                nameValuePairs.add(new BasicNameValuePair("install_id", mWiz.getInstallationId()));
                nameValuePairs.add(new BasicNameValuePair("request_id", UUID.randomUUID().toString()));
                nameValuePairs.add(new BasicNameValuePair("language", Locale.getDefault().getLanguage()));
                nameValuePairs.add(new BasicNameValuePair("country", Locale.getDefault().getCountry()));
                nameValuePairs.add(new BasicNameValuePair("app_id", CloudConstants.APP_ID));
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                // Execute HTTP Post Request
                HttpResponse response = mHttpClient.execute(httppost);

                int statusCode = response.getStatusLine().getStatusCode();
                if (statusCode == 200) {
                    mUIHandler.post(new SafeRunnable() {
                        @Override
                        protected void safeRun() throws Exception {
                            T.UI();
                            mWiz.setEmail(email);
                            mWiz.save();
                            progressDialog.dismiss();
                            mWiz.proceedToNextPage();
                            showNotification();
                        }
                    });
                } else if (statusCode == 502) {

                    final HttpEntity entity = response.getEntity();
                    mUIHandler.post(new SafeRunnable() {
                        @Override
                        protected void safeRun() throws Exception {
                            T.UI();
                            progressDialog.dismiss();
                            AlertDialog.Builder builder = new AlertDialog.Builder(RegistrationActivity2.this);

                            boolean stringSet = false;
                            if (entity != null) {
                                @SuppressWarnings("unchecked")
                                final Map<String, Object> responseMap = (Map<String, Object>) org.json.simple.JSONValue
                                        .parse(new InputStreamReader(entity.getContent()));

                                if (responseMap != null) {
                                    String result = (String) responseMap.get("result");
                                    if (result != null) {
                                        builder.setMessage(result);
                                        stringSet = true;
                                    }
                                }
                            }

                            if (!stringSet) {
                                builder.setMessage(R.string.registration_email_not_valid);
                            }

                            builder.setPositiveButton(R.string.rogerthat, null);
                            AlertDialog dialog = builder.create();
                            dialog.show();
                        }
                    });
                } else {
                    mUIHandler.post(showErrorDialog);
                }

            } catch (ClientProtocolException e) {
                L.d(e);
                mUIHandler.post(showErrorDialog);
            } catch (IOException e) {
                L.d(e);
                mUIHandler.post(showErrorDialog);
            }
        }
    });
}

From source file:org.zywx.wbpalmstar.engine.EBrowserWindow.java

public void createProgressDialog(String title, String content, boolean isCancel) {
    if (mGlobalProDialog == null) {
        mGlobalProDialog = new ProgressDialog(mContext, ProgressDialog.THEME_HOLO_DARK);
    }// ww  w  .j a v  a2s .c  om
    mGlobalProDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    if (!TextUtils.isEmpty(title)) {
        mGlobalProDialog.setTitle(title);
    }
    mGlobalProDialog.setMessage(content);
    mGlobalProDialog.setCancelable(isCancel);
    mGlobalProDialog.show();
}

From source file:com.android.mms.ui.MessageUtils.java

/**
 * Gets a delete progress dialog.//from   w w w . ja  va  2 s.  c o m
 * @param context the activity context.
 * @return the delete progress dialog.
 */
public static NewProgressDialog getProgressDialog(Context context) {
    NewProgressDialog dialog = new NewProgressDialog(context);
    dialog.setCancelable(false);
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setMessage(context.getString(R.string.deleting));
    dialog.setMax(1); /* default is one complete */
    // ignore the search key, when deleting we do not want the search bar come out.
    dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            return (keyCode == KeyEvent.KEYCODE_SEARCH);
        }
    });
    return dialog;
}

From source file:com.android.mms.ui.MessageUtils.java

/**
 * Gets a search progress dialog.//from   ww  w  .j  av  a  2 s  . c o m
 * @param context the activity context.
 * @return the search progress dialog.
 */
public static NewProgressDialog getProgressDialog(Context context) {
    NewProgressDialog dialog = new NewProgressDialog(context);
    dialog.setCancelable(false);
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setMessage(context.getString(R.string.refreshing));
    dialog.setMax(1); /* default is one complete */
    // ignore the search key, when searching we do not want the search bar come out.
    dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            return (keyCode == KeyEvent.KEYCODE_SEARCH);
        }
    });
    return dialog;
}