Example usage for android.app ProgressDialog ProgressDialog

List of usage examples for android.app ProgressDialog ProgressDialog

Introduction

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

Prototype

public ProgressDialog(Context context) 

Source Link

Document

Creates a Progress dialog.

Usage

From source file:Main.java

public static void showProgressDialog(final Activity context, final String dialogTitle,
        final String dialogMessage) {
    if (context == null) {
        return;/*w  ww .  j  ava  2  s . c o m*/
    }
    context.runOnUiThread(new Runnable() {
        @Override
        public void run() {

            if (progressDialog == null) {
                progressDialog = new ProgressDialog(context);
            }
            if (progressDialog.isShowing() == true) {
                progressDialog.dismiss();
            }
            if (dialogTitle != null && !"".equals(dialogTitle.trim())) {
                progressDialog.setTitle(dialogTitle);
            }
            if (dialogMessage != null && !"".equals(dialogMessage.trim())) {
                progressDialog.setMessage(dialogMessage);
            }
            progressDialog.setCanceledOnTouchOutside(false);
            progressDialog.show();
        }
    });
}

From source file:Main.java

public static ProgressDialog creativeProgressBar(Context context, String comment) {
    ProgressDialog dialog = new ProgressDialog(context);
    if (comment == null)
        dialog.setMessage("Please wait while loading...");
    else// w w  w . j  a  va2 s. c om
        dialog.setMessage(comment);

    dialog.setIndeterminate(true);
    dialog.setCancelable(true);
    return dialog;
}

From source file:com.nkahoang.screenstandby.settings.UpdateChecker.java

public static void CheckForUpdate(Context c) {
    progressDialog = new ProgressDialog(c);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER | ProgressDialog.THEME_HOLO_DARK);
    progressDialog.setTitle("Checking for update");
    progressDialog.setMessage("Please wait...\n");
    progressDialog.setCancelable(false);
    progressDialog.setIcon(android.R.drawable.ic_menu_upload);
    progressDialog.setIndeterminate(true);
    progressDialog.show();//from  ww  w  .j a  va  2s.c o m
    new LoadViewTask(c).execute();
}

From source file:com.muzima.tasks.ValidateURLTask.java

@Override
protected void onPreExecute() {
    super.onPreExecute();
    progressDialog = new ProgressDialog(settingsActivity);
    progressDialog.setMessage("Step 1: Validating URL");
    progressDialog.show();//from   ww  w  .  jav  a 2  s. c o  m
}

From source file:com.ilearnrw.reader.tasks.ProfileTask.java

@Override
protected void onPreExecute() {
    dialog = new ProgressDialog(context);
    dialog.setTitle(context.getString(R.string.dialog_fetch_user_profile_title));
    dialog.setMessage(context.getString(R.string.dialog_fetch_user_profile_summary));
    dialog.setCancelable(true);/* www .j av a 2 s .  c  om*/
    dialog.setCanceledOnTouchOutside(false);
    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    cancel(true);
                    dialog.dismiss();
                }
            });
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            cancel(true);
            dialog.dismiss();
        }
    });
    dialog.show();

    super.onPreExecute();
}

From source file:com.ilearnrw.reader.tasks.LoginTask.java

@Override
protected void onPreExecute() {
    dialog = new ProgressDialog(context);
    dialog.setTitle(context.getString(R.string.dialog_login_title));
    dialog.setMessage(context.getString(R.string.dialog_login_message));
    dialog.setCancelable(true);/*from ww w . ja v  a 2s  .c  o m*/
    dialog.setCanceledOnTouchOutside(false);
    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    cancel(true);
                    dialog.dismiss();
                }
            });
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            cancel(true);
            dialog.dismiss();
        }
    });
    dialog.show();
    super.onPreExecute();
}

From source file:com.cybussolutions.wikki.afri_pay.Networking.CheckAmount.java

@Override
protected void onPreExecute() {
    bar = new ProgressDialog(this.context);
    bar.setMessage("Loading...");
    bar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    bar.setCancelable(false);//from  www  .  j ava 2  s. com
    //bar.show();
}

From source file:com.xfinity.ceylon_steel.controller.CustomerController.java

public static void downloadCustomers(final Context context) {
    new AsyncTask<User, Void, JSONArray>() {

        @Override/*from ww  w .ja  v a2 s  .c  o m*/
        protected void onPreExecute() {
            if (UserController.progressDialog == null) {
                UserController.progressDialog = new ProgressDialog(context);
                UserController.progressDialog.setMessage("Downloading Data");
                UserController.progressDialog.setCanceledOnTouchOutside(false);
            }
            if (!UserController.progressDialog.isShowing()) {
                UserController.progressDialog.show();
            }
        }

        @Override
        protected JSONArray doInBackground(User... users) {
            try {
                User user = users[0];
                HashMap<String, Object> parameters = new HashMap<String, Object>();
                parameters.put("userId", user.getUserId());
                return getJsonArray(getCustomersOfUser, parameters, context);
            } catch (IOException ex) {
                Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex);
            } catch (JSONException ex) {
                Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex);
            }
            return null;
        }

        @Override
        protected void onPostExecute(JSONArray result) {
            if (UserController.atomicInteger.decrementAndGet() == 0 && UserController.progressDialog != null
                    && UserController.progressDialog.isShowing()) {
                UserController.progressDialog.dismiss();
                UserController.progressDialog = null;
            }
            if (result != null) {
                SQLiteDatabaseHelper databaseInstance = SQLiteDatabaseHelper.getDatabaseInstance(context);
                SQLiteDatabase database = databaseInstance.getWritableDatabase();
                SQLiteStatement compiledStatement = database
                        .compileStatement("replace into tbl_customer(customerId,customerName) values(?,?)");
                try {
                    database.beginTransaction();
                    for (int i = 0; i < result.length(); i++) {
                        JSONObject customer = result.getJSONObject(i);
                        compiledStatement.bindAllArgsAsStrings(
                                new String[] { Integer.toString(customer.getInt("customerId")),
                                        customer.getString("customerName") });
                        long response = compiledStatement.executeInsert();
                        if (response == -1) {
                            return;
                        }
                    }
                    database.setTransactionSuccessful();
                    Toast.makeText(context, "Customers downloaded successfully", Toast.LENGTH_SHORT).show();
                } catch (JSONException ex) {
                    Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex);
                    Toast.makeText(context, "Unable parse customers", Toast.LENGTH_SHORT).show();
                } finally {
                    database.endTransaction();
                    databaseInstance.close();
                }
            } else {
                Toast.makeText(context, "Unable to download customers", Toast.LENGTH_SHORT).show();
            }
        }

    }.execute(UserController.getAuthorizedUser(context));
}

From source file:net.evecom.android.util.HttpMultipartPost.java

@Override
protected void onPreExecute() {
    pd = new ProgressDialog(context);
    pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    pd.setMessage("Uploading Picture...");
    pd.setCancelable(false);//from  w w w. j a va  2  s .c  om
    pd.show();
}

From source file:com.parking.auth.LoginUserAsyncTask.java

public LoginUserAsyncTask(AsyncTaskResultNotifierInterface loginNotifier, Context context) {
    this.notifier = loginNotifier;
    this.context = context;
    dialog = new ProgressDialog(this.context);
}