Example usage for android.app ProgressDialog show

List of usage examples for android.app ProgressDialog show

Introduction

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

Prototype

public static ProgressDialog show(Context context, CharSequence title, CharSequence message) 

Source Link

Document

Creates and shows a ProgressDialog.

Usage

From source file:ch.eitchnet.android.mabea.activity.TodayFragment.java

private boolean checkConnection() {
    MabeaContext context = MabeaApplication.getContext();
    MabeaConnection connection = context.getConnection();

    if (!connection.needsRefresh()) {
        return true;
    }/*from w w  w.j av a  2s .  c  om*/

    SyncExec action = new SyncExec() {
        @Override
        protected void execute() {
            String title = "Refreshing connection";
            String msg = "Connection needs to be refreshed, please wait...";
            progressDlg = ProgressDialog.show(getActivity(), title, msg);
        }
    };
    action.runOnUiThread(getActivity());

    Logger.i(TAG, "toggleLoginState", "refreshing connection...");

    State state = connection.checkConnection();
    if (state == State.UNKNOWN) {
        String title = "Toggling login state failed";
        String msg = "Connection could not be verified due to error: " + connection.getErrorMsg();
        DialogUtil.showErrorDialog(getActivity(), title, msg);
    }

    if (progressDlg != null)
        progressDlg.dismiss();

    return !connection.hasError();
}

From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderFE.java

@Override
protected void fetchDatabase(final DownloadItem di) {
    View alertView = View.inflate(this, R.layout.link_alert, null);
    TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setText(//from w  w w  .j av  a2s  .c  om
            Html.fromHtml(getString(R.string.downloader_download_alert_message) + di.getDescription()));

    new AlertDialog.Builder(this).setView(alertView)
            .setTitle(getString(R.string.downloader_download_alert) + di.getTitle())
            .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface arg0, int arg1) {
                    mProgressDialog = ProgressDialog.show(DownloaderFE.this,
                            getString(R.string.loading_please_wait), getString(R.string.loading_downloading));
                    new Thread() {
                        public void run() {
                            try {
                                downloadDatabase(di);
                                mHandler.post(new Runnable() {
                                    public void run() {
                                        mProgressDialog.dismiss();
                                        String dbpath = Environment.getExternalStorageDirectory()
                                                .getAbsolutePath() + getString(R.string.default_dir);
                                        new AlertDialog.Builder(DownloaderFE.this)
                                                .setTitle(R.string.downloader_download_success)
                                                .setMessage(
                                                        getString(R.string.downloader_download_success_message)
                                                                + dbpath + di.getTitle() + ".db")
                                                .setPositiveButton(R.string.ok_text, null).create().show();
                                    }
                                });

                            } catch (final Exception e) {
                                Log.e(TAG, "Error downloading", e);
                                mHandler.post(new Runnable() {
                                    public void run() {
                                        mProgressDialog.dismiss();
                                        new AlertDialog.Builder(DownloaderFE.this)
                                                .setTitle(R.string.downloader_download_fail)
                                                .setMessage(getString(R.string.downloader_download_fail_message)
                                                        + " " + e.toString())
                                                .setPositiveButton(R.string.ok_text, null).create().show();
                                    }
                                });
                            }
                        }
                    }.start();
                }
            }).setNegativeButton(getString(R.string.no_text), null).show();
}

From source file:com.ibuildapp.romanblack.TableReservationPlugin.TableReservationEMailSignUpActivity.java

private void showProgressDialog() {
    if (progressDialog == null) {
        progressDialog = ProgressDialog.show(this, null,
                getResources().getString(R.string.common_registration_upper));
    } else {//from w w  w .j a  v  a 2s. co  m
        if (!progressDialog.isShowing()) {
            progressDialog = ProgressDialog.show(this, null,
                    getResources().getString(R.string.common_registration_upper));
        }
    }
}

From source file:com.adwardstark.lyricswithmusixmatchapi.MainActivity.java

private void getLyricsForTheSong(final String track_id) {
    try {//w  w w . j a v a2s.  c om

        class GetLyricsAsync extends AsyncTask<String, Void, String> {

            private Dialog loadingDialog;

            @Override
            protected void onPreExecute() {
                super.onPreExecute();
                loadingDialog = ProgressDialog.show(MainActivity.this, "Please wait",
                        "Searching for lyrics...");
            }

            @Override
            protected String doInBackground(String... params) {

                String result = null;
                InputStream inputStream = null;
                try {
                    String link = "http://api.musixmatch.com/ws/1.1/track.lyrics.get?apikey=" + apiKey
                            + "&track_id=" + track_id + "&format=json";
                    URL url = new URL(link);
                    HttpClient client = new DefaultHttpClient();
                    HttpGet request = new HttpGet();
                    request.setURI(new URI(link));
                    HttpResponse response = client.execute(request);

                    HttpEntity entity = response.getEntity();

                    inputStream = entity.getContent();
                    // json is UTF-8 by default
                    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 8);
                    StringBuilder sb = new StringBuilder();

                    String line = null;
                    while ((line = reader.readLine()) != null) {
                        sb.append(line + "\n");
                    }
                    result = sb.toString();
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    try {
                        if (inputStream != null)
                            inputStream.close();
                    } catch (Exception squish) {
                    }
                }
                return result;
            }

            @Override
            protected void onPostExecute(String result) {
                myJSON = result;
                loadingDialog.dismiss();
                checkLyrics();
            }
        }

        GetLyricsAsync la = new GetLyricsAsync();
        la.execute();
    } catch (Exception ex) {
        Toast.makeText(getBaseContext(), "You are not connected", Toast.LENGTH_LONG).show();
    }

}

From source file:eu.operando.proxy.OperandoProxyStatus.java

private void installCert()
        throws RootCertificateException, GeneralSecurityException, OperatorCreationException, IOException {

    new AsyncTask<Void, Void, Certificate>() {
        Exception error;/*w w  w  .  j av  a 2  s .  co m*/
        ProgressDialog dialog;

        @Override
        protected void onPreExecute() {
            dialog = ProgressDialog.show(MainProxyActivity.this, null, "Generating SSL certificate...");
            dialog.setCancelable(false);
        }

        @Override
        protected Certificate doInBackground(Void... params) {
            try {
                Certificate cert = BouncyCastleSslEngineSource
                        .initializeKeyStoreStatic(mainContext.getAuthority());
                return cert;
            } catch (Exception e) {
                error = e;
                return null;
            }
        }

        @Override
        protected void onPostExecute(Certificate certificate) {
            dialog.dismiss();

            if (certificate != null) {
                Intent intent = KeyChain.createInstallIntent();
                try {
                    intent.putExtra(KeyChain.EXTRA_CERTIFICATE, certificate.getEncoded());
                } catch (CertificateEncodingException e) {
                    e.printStackTrace();
                }
                intent.putExtra(KeyChain.EXTRA_NAME, mainContext.getAuthority().commonName());
                startActivityForResult(intent, 1);
            } else {
                Toast.makeText(MainProxyActivity.this,
                        "Failed to load certificates, exiting: " + error.getMessage(), Toast.LENGTH_LONG)
                        .show();
                finish();
            }
        }
    }.execute();

}

From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderSS.java

protected void fetchDatabase(final DownloadItem di) {
    View alertView = View.inflate(this, R.layout.link_alert, null);
    TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setText(/*from w w w.  ja v a2  s.c  o  m*/
            Html.fromHtml(getString(R.string.downloader_download_alert_message) + di.getDescription()));

    new AlertDialog.Builder(this).setView(alertView)
            .setTitle(getString(R.string.downloader_download_alert) + di.getTitle())
            .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface arg0, int arg1) {
                    mProgressDialog = ProgressDialog.show(DownloaderSS.this,
                            getString(R.string.loading_please_wait), getString(R.string.loading_downloading));
                    new Thread() {
                        public void run() {
                            try {
                                downloadDatabase(di);
                                mHandler.post(new Runnable() {
                                    public void run() {
                                        mProgressDialog.dismiss();
                                        String dbpath = Environment.getExternalStorageDirectory()
                                                .getAbsolutePath() + getString(R.string.default_dir);
                                        new AlertDialog.Builder(DownloaderSS.this)
                                                .setTitle(R.string.downloader_download_success)
                                                .setMessage(
                                                        getString(R.string.downloader_download_success_message)
                                                                + dbpath + di.getTitle() + ".db")
                                                .setPositiveButton(R.string.ok_text, null).create().show();
                                    }
                                });

                            } catch (final Exception e) {
                                Log.e(TAG, "Error downloading", e);
                                mHandler.post(new Runnable() {
                                    public void run() {
                                        mProgressDialog.dismiss();
                                        new AlertDialog.Builder(DownloaderSS.this)
                                                .setTitle(R.string.downloader_download_fail)
                                                .setMessage(getString(R.string.downloader_download_fail_message)
                                                        + " " + e.toString())
                                                .setPositiveButton(R.string.ok_text, null).create().show();
                                    }
                                });
                            }
                        }
                    }.start();
                }
            }).setNegativeButton(getString(R.string.no_text), null).show();
}

From source file:be.vbsteven.bmtodesk.ShareActivity.java

/**
 * shows the progress dialog/*  w  ww .j av  a  2  s  . c o m*/
 */
private void showProgress() {
    if (progress != null) {
        progress.dismiss();
    }

    progress = ProgressDialog.show(this, "Bookmark to Desktop", "Sending bookmark to server...");
}

From source file:com.mani.volleydemo.JSONObjectRequestActvity.java

private void showProgress() {
    mProgress = ProgressDialog.show(this, "", "Loading...");
}

From source file:org.loon.framework.android.game.LGameActivity.java

/**
 * ??Progress//from w  w  w  . j a  va  2 s  .  co  m
 * 
 * @param title
 * @param message
 * @return
 */
public AlertDialog showAndroidProgress(final String title, final String message) {
    if (alert == null || !alert.isShowing()) {
        Runnable showProgress = new Runnable() {
            public void run() {
                alert = ProgressDialog.show(LGameActivity.this, title, message);
            }
        };
        runOnUiThread(showProgress);
    }
    return alert;
}

From source file:me.henrytao.bootstrapandroidlibrarydemo.activity.BaseActivity.java

private void showProgressDialog(CharSequence title, CharSequence message) {
    if (isFinishing()) {
        return;/*from w  w  w.  ja  v a  2s . c  om*/
    }
    hideProgressDialog();
    mProgressDialog = ProgressDialog.show(this, title, message);
}