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,
        boolean indeterminate, boolean cancelable, OnCancelListener cancelListener) 

Source Link

Document

Creates and shows a ProgressDialog.

Usage

From source file:com.seleuco.mame4droid.NetPlay.java

public void createGame() {

    String strPort = mm.getPrefsHelper().getNetplayPort();
    int port = 0;
    try {/*from  w  w w. j av a  2s.  c  om*/
        port = Integer.parseInt(strPort);
    } catch (Exception e) {
    }
    if (!(port >= 1024 && port <= 32768 * 2)) {
        Toast.makeText(mm, "Invalid Port", Toast.LENGTH_SHORT).show();
        return;
    }

    if (Emulator.netplayInit(null, port, 0) == -1) {
        Toast.makeText(mm, "Error initializing Netplay!", Toast.LENGTH_SHORT).show();
        return;
    }

    //netplayDlg.hide();

    canceled = false;
    progressDialog = ProgressDialog.show(mm, "Press back to cancel", "Creating game at ...", true, true,
            new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    canceled = true;
                }
            });

    Thread t = new Thread(new Runnable() {
        public void run() {
            final String ip = getIPAddress();
            if (ip == null) {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                canceled = true;
                mm.runOnUiThread(new Runnable() {
                    public void run() {
                        Toast.makeText(mm, "No IP address available!. Is Wi-Fi enabled?", Toast.LENGTH_LONG)
                                .show();
                    }
                });
            }
            mm.runOnUiThread(new Runnable() {
                public void run() {
                    progressDialog.setMessage("Waiting for peer...\nCreating game at :" + ip);
                }
            });
            while (Emulator.getValue(Emulator.NETPLAY_HAS_JOINED) == 0 && !canceled) {
                try {
                    Thread.sleep(1000);
                    //System.out.println("Esperando...");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            if (progressDialog != null && progressDialog.isShowing()) {
                progressDialog.dismiss();
            }

            if (canceled) {
                Emulator.setValue(Emulator.NETPLAY_HAS_CONNECTION, 0);
            } else {
                Emulator.setValue(Emulator.EXIT_GAME_KEY, 1);
            }
            mm.runOnUiThread(new Runnable() {
                public void run() {
                    if (!canceled) {
                        if (netplayDlg.isShowing())
                            netplayDlg.hide();
                        Toast.makeText(mm, "Connected. Starting Netplay!", Toast.LENGTH_SHORT).show();
                        Emulator.resume();
                    }
                }
            });
        }
    });
    t.start();
}

From source file:com.foundstone.certinstaller.CertInstallerActivity.java

/**
 * Install the site certificate. First check if we have the certificate, if
 * not open a connection and grab the certificates. Once the certificates
 * are found launch intent with an X509Cert to be installed to the KeyChain.
 * /*from ww w. j a  v a  2  s. com*/
 * @param urlString
 * @param proxyIP
 * @param proxyPort
 */
private void installSiteCert(String urlString, String proxyIP, String proxyPort) {
    if (TextUtils.isEmpty(urlString)) {
        Toast.makeText(getApplicationContext(), "URL is not set", Toast.LENGTH_SHORT).show();
        Log.d(TAG, "URL was not set");
        return;
    } else if (TextUtils.isEmpty(proxyIP)) {
        Toast.makeText(getApplicationContext(), "Port is not set", Toast.LENGTH_SHORT).show();
        Log.d(TAG, "Port is not set");
        return;
    }
    if (siteCert == null) {
        pd = ProgressDialog.show(CertInstallerActivity.this, "Getting the Site certificate", "", true, false,
                null);

        grabCerts(urlString, proxyIP, proxyPort);
        pd.dismiss();
    }
    try {
        installCert(siteCert, CertUtils.INSTALL_SITE_CODE);
    } catch (Exception e) {
        setSiteTextNotInstalled();
        e.printStackTrace();
    }
}

From source file:com.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java

private void startSpinner(boolean isScan) {
    mProgressDialog = ProgressDialog.show(this,
            isScan ? getString(R.string.processing_scan, getString(R.string.app_name))
                    : getString(R.string.processing_invitation),
            getString(R.string.retrieving_information), true, true, new DialogInterface.OnCancelListener() {
                @Override/*from   w w w .  j a  v  a  2 s  .c o m*/
                public void onCancel(DialogInterface dialog) {
                    T.UI();
                    finish();
                }
            });
}

From source file:com.seleuco.mame4droid.NetPlay.java

public void joinGame(String addr) {

    String strPort = mm.getPrefsHelper().getNetplayPort();
    int port = 0;
    try {/* ww w.  jav  a  2  s. c o  m*/
        port = Integer.parseInt(strPort);
    } catch (Exception e) {
    }
    if (!(port >= 1024 && port <= 32768 * 2)) {
        Toast.makeText(mm, "Invalid Port", Toast.LENGTH_SHORT).show();
        return;
    }

    if (Emulator.netplayInit(addr, port, 0) == -1) {
        Toast.makeText(mm, "Error initializing Netplay!", Toast.LENGTH_SHORT).show();
        return;
    }

    //netplayDlg.hide();

    canceled = false;
    progressDialog = ProgressDialog.show(mm, "Press back to cancel", "Connecting to :" + addr, true, true,
            new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    canceled = true;
                }
            });

    Thread t = new Thread(new Runnable() {
        public void run() {
            while (Emulator.getValue(Emulator.NETPLAY_HAS_JOINED) == 0 && !canceled) {
                try {
                    if (Emulator.netplayInit(null, 0, 1) == -1)
                        canceled = true;
                    Thread.sleep(1000);
                    //System.out.println("Esperando...");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            if (progressDialog != null && progressDialog.isShowing()) {
                progressDialog.dismiss();
            }

            if (canceled) {
                Emulator.setValue(Emulator.NETPLAY_HAS_CONNECTION, 0);
            } else {
                Emulator.setValue(Emulator.EXIT_GAME_KEY, 1);
            }

            mm.runOnUiThread(new Runnable() {
                public void run() {
                    if (!canceled) {
                        if (netplayDlg.isShowing())
                            netplayDlg.hide();
                        Toast.makeText(mm, "Connected. Starting Netplay!", Toast.LENGTH_SHORT).show();
                        Emulator.resume();
                    }
                }
            });
        }
    });
    t.start();
}

From source file:edu.pitt.gis.uniapp.UniApp.java

/**
  * Show the spinner.  Must be called from the UI thread.
  *//from  w w  w.ja va 2s. c om
  * @param title         Title of the dialog
  * @param message       The message of the dialog
  */
public void spinnerStart(final String title, final String message) {
    if (this.spinnerDialog != null) {
        this.spinnerDialog.dismiss();
        this.spinnerDialog = null;
    }
    final UniApp me = this;
    this.spinnerDialog = ProgressDialog.show(UniApp.this, title, message, true, true,
            new DialogInterface.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    me.spinnerDialog = null;
                }
            });
}

From source file:net.bytten.comicviewer.ComicViewerActivity.java

public void loadComicImage(Uri uri) {
    webview.clearView();//from w  w  w .j  a  v a  2  s.c o  m
    final ProgressDialog pd = ProgressDialog.show(this, getStringAppName(), "Loading comic image...", false,
            true, new OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    webview.stopLoading();
                    webview.requestFocus();
                }
            });
    pd.setProgress(0);
    webview.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            pd.dismiss();
            webview.requestFocus();
        }
    });
    webview.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            pd.setProgress(newProgress * 100);
        }
    });
    if ("".equals(uri.toString())) {
        failed("Couldn't identify image in post");
        webview.loadUrl("about:blank");
    } else {
        webview.loadUrl(uri.toString());
    }
}

From source file:cc.mintcoin.wallet.ui.SendCoinsFragment.java

private void requestPaymentRequest(final String paymentRequestUrl) {
    final String host = Uri.parse(paymentRequestUrl).getHost();
    final ProgressDialog progressDialog = ProgressDialog.show(activity, null,
            getString(R.string.send_coins_fragment_request_payment_request_progress, host), true, true, null);

    new RequestPaymentRequestTask.HttpRequestTask(backgroundHandler,
            new RequestPaymentRequestTask.ResultCallback() {
                @Override/*from  w  w  w. j  a  v  a 2  s  . c  o  m*/
                public void onPaymentIntent(final PaymentIntent paymentIntent) {
                    progressDialog.dismiss();

                    if (SendCoinsFragment.this.paymentIntent.isSecurityExtendedBy(paymentIntent)) {
                        updateStateFrom(paymentIntent);
                    } else {
                        final DialogBuilder dialog = DialogBuilder.warn(activity,
                                R.string.send_coins_fragment_request_payment_request_failed_title);
                        dialog.setMessage(getString(
                                R.string.send_coins_fragment_request_payment_request_wrong_signature));
                        dialog.singleDismissButton(null);
                        dialog.show();
                    }
                }

                @Override
                public void onFail(final int messageResId, final Object... messageArgs) {
                    progressDialog.dismiss();

                    final DialogBuilder dialog = DialogBuilder.warn(activity,
                            R.string.send_coins_fragment_request_payment_request_failed_title);
                    dialog.setMessage(getString(messageResId, messageArgs));
                    dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int which) {
                            requestPaymentRequest(paymentRequestUrl);
                        }
                    });
                    dialog.setNegativeButton(R.string.button_dismiss, null);
                    dialog.show();
                }
            }, application.httpUserAgent()).requestPaymentRequest(paymentRequestUrl);
}