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:org.openremote.android.console.AppSettingsActivity.java

private void retrieveCertificate() {
    final Button doneButton = (Button) findViewById(R.id.setting_done);
    doneButton.setEnabled(false);/* w w w.j a v  a2  s.  c  om*/
    final ProgressDialog dialog = ProgressDialog.show(this, "Fetching certificate",
            "Busy fetching certificate");

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            doneButton.setEnabled(true);
            dialog.cancel();
            switch (msg.what) {
            case -1:
                ViewHelper.showAlertViewWithTitle(AppSettingsActivity.this, "Connection error",
                        "Can't connect to the server.");
                break;
            case 0:
                startMain();
                break;
            case 1:
                ViewHelper.showAlertViewWithTitle(AppSettingsActivity.this, "No access",
                        "You don't have access.\nPlease ask the administrator for permission.");
                break;
            case 2:
                ViewHelper.showAlertViewWithTitle(AppSettingsActivity.this, "No access",
                        "You don't have access.\nYour certificate is invalid.");
                break;
            case 3:
                ViewHelper.showAlertViewWithTitle(AppSettingsActivity.this, "No access",
                        "You don't have access.\nYour certificate expired.");
                break;
            }
        }
    };

    ORKeyStore.getInstance(getApplicationContext())
            .checkCertificateChain(AppSettingsModel.getCurrentServer(getApplicationContext()), handler);
}

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

private void DownloadInitialSettings() {

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getBoolean("firstTime", true) && haveNetworkConnection()) {
        // run one time code here
        final File tmp = new File(getFilesDir(), "domainfilters_" + System.currentTimeMillis());
        try {//  ww  w  .  j  a  v  a2s .c o  m
            new DownloadTask(MainActivity.this, new URL(DatabaseHelper.serverUrl + "/blocked_urls"), tmp,
                    new DownloadTask.Listener() {
                        @Override
                        public void onCompleted() {
                            new AsyncTask<Void, Void, Integer>() {
                                ProgressDialog dialog;

                                @Override
                                protected void onPreExecute() {
                                    dialog = ProgressDialog.show(MainActivity.this, null,
                                            "Applying up to date settings for your convenience, to keep you safe.\nThis might take while...");
                                    dialog.setCancelable(false);
                                }

                                @Override
                                protected Integer doInBackground(Void... params) {
                                    new DatabaseHelper(MainActivity.this)
                                            .deleteDomainFilterFile(DatabaseHelper.serverUrl);
                                    Integer count = 0;
                                    BufferedReader br = null;
                                    try {
                                        br = new BufferedReader(new FileReader(tmp));
                                        String line;
                                        while ((line = br.readLine()) != null) {
                                            int hash = line.indexOf('#');
                                            if (hash >= 0)
                                                line = line.substring(0, hash);
                                            line = line.trim();
                                            try {
                                                String blockedDomain = line;
                                                if (blockedDomain.equals("local")
                                                        || StringUtils.containsAny(blockedDomain, "localhost",
                                                                "127.0.0.1", "broadcasthost"))
                                                    continue;
                                                DomainFilter domainFilter = new DomainFilter();
                                                domainFilter.setContent(blockedDomain);
                                                domainFilter.setSource(DatabaseHelper.serverUrl);
                                                domainFilter.setIsWildcard(false);
                                                new DatabaseHelper(MainActivity.this)
                                                        .createDomainFilter(domainFilter);
                                                count++;
                                            } catch (Exception e) {
                                                Log.i("Error", "Invalid hosts file line: " + line);
                                            }
                                        }
                                        Log.i("Error", count + " entries read");
                                    } catch (IOException ex) {
                                        Log.e("Error", ex.toString() + "\n" + Log.getStackTraceString(ex));
                                    } finally {
                                        if (br != null)
                                            try {
                                                br.close();
                                            } catch (IOException exex) {
                                                Log.e("Error",
                                                        exex.toString() + "\n" + Log.getStackTraceString(exex));
                                            }
                                    }
                                    return count;
                                }

                                @Override
                                protected void onPostExecute(Integer count) {
                                    dialog.dismiss();
                                    // mark first time has runned.
                                    SharedPreferences.Editor editor = prefs.edit();
                                    editor.putBoolean("firstTime", false);
                                    editor.commit();
                                }
                            }.execute();
                        }

                        @Override
                        public void onCancelled() {
                            if (tmp.exists())
                                tmp.delete();
                        }

                        @Override
                        public void onException(Throwable ex) {
                            if (tmp.exists())
                                tmp.delete();

                            ex.printStackTrace();
                            Toast.makeText(MainActivity.this, ex.getMessage(), Toast.LENGTH_LONG).show();
                        }
                    }).execute();
        } catch (MalformedURLException mue) {
            mue.getMessage();
        }
    } else if (!haveNetworkConnection()) {
        Toast.makeText(MainActivity.this, "You don't seem to have a working Internet Connection.",
                Toast.LENGTH_LONG).show();
    }
}

From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java

/** onGpsClicked
 * activates the gps when gps button is clicked, and fills the acFrom field with the gps info
 * @param view/*ww  w .  j a v a  2 s.c o m*/
 */
public void onGpsClicked(View view) {
    final GpsHandler gps = new GpsHandler(this);
    if (!gps.gpsEnabled()) {
        Toast.makeText(this, "GPS is not activated", Toast.LENGTH_LONG).show();
        return;
    }

    loadingDialog = ProgressDialog.show(this, "Locating", "Finding your location");
    loadingDialog.setCancelable(true);
    loadingDialog.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            gps.abortGPS();
            loadingDialog.dismiss();
        }
    });
    gps.findLocation();
    new Thread() {
        public void run() {
            try {
                sleep(60000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            loadingDialog.dismiss();
            gps.abortGPS();
        }
    }.start();

}

From source file:net.evecom.android.PublicOpinionLookActivity.java

/**
 * /*from w  w  w.  j  a  v  a 2 s  . c  o m*/
 * 
 * @param v
 */
public void opinion_more_delete(View v) {

    final AlertDialog.Builder builder = new AlertDialog.Builder(PublicOpinionLookActivity.this);
    builder.setTitle("");
    builder.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder.setMessage("");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            progressDialog = ProgressDialog.show(PublicOpinionLookActivity.this, "", "...");

            formSubmit();

        }
    });
    builder.setNegativeButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();

}