Example usage for android.app ProgressDialog dismiss

List of usage examples for android.app ProgressDialog dismiss

Introduction

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

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:app.view.chat.ContactListFragment.java

/**
 * ?/* w  ww .ja v a2s  .  co m*/
 *
 * @param tobeDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("...");
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                DemoApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), ": " + e.getMessage(), Toast.LENGTH_LONG)
                                .show();
                    }
                });

            }

        }
    }).start();

}

From source file:eu.dirtyharry.androidopsiadmin.Main.java

public void getOPSIDepots() {

    final ProgressDialog dialog = ProgressDialog.show(Main.this, getString(R.string.gen_title_pleasewait),
            getString(R.string.pd_getdepots), true);
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();
            if (GlobalVar.getInstance().getError().equals("null")) {
                if (doit.equals("true")) {

                    JSONArray result = new JSONArray();
                    try {
                        result = opsiresult.getJSONArray("result");
                        depots = new String[result.length()];
                        for (int i = 0; i < result.length(); i++) {
                            depots[i] = result.getString(i);
                        }/*from   ww  w. j av a2  s  .com*/
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    AlertDialog.Builder builder = new AlertDialog.Builder(Main.this);
                    builder.setTitle(getString(R.string.gen_choose));
                    builder.setSingleChoiceItems(depots, -1, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int item) {
                            dialog.dismiss();
                            String depot = depots[item];
                            choosendepot = depot;

                            getOPSIDepotConfig(depot);

                        }
                    });
                    AlertDialog alert = builder.create();
                    alert.show();

                } else if (doit.equals("serverdown")) {
                    Toast.makeText(Main.this, String.format(getString(R.string.to_servernotrechable), serverip),
                            // serverip + " "
                            // + getString(R.string.to_servernotrechable),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                        GlobalVar.getInstance().getError(), false);
            }

        }
    };
    Thread checkUpdate = new Thread() {
        public void run() {
            Looper.prepare();
            JSONArray JSONparams = new JSONArray();
            if (Networking.isServerUp(serverip, serverport, serverusername, serverpasswd)) {
                opsiresult = new JSONObject();
                opsiresult = eu.dirtyharry.androidopsiadmin.Networking.opsiGetJSONObject("rpc", serverip,
                        serverport, "getDepotIds_list", JSONparams, serverusername, serverpasswd);
                doit = "true";
            } else {
                doit = "serverdown";
                //
            }
            handler.sendEmptyMessage(0);
        }
    };
    checkUpdate.start();
}

From source file:com.brq.wallet.external.cashila.activity.CashilaPendingFragment.java

private void getBillPays(boolean showProgress, boolean fromCache) {
    final ProgressDialog progressDialog;
    if (showProgress) {
        progressDialog = ProgressDialog.show(this.getActivity(), getResources().getString(R.string.cashila),
                getResources().getString(R.string.cashila_fetching), true);
    } else {//from www. j a va 2 s .c o m
        progressDialog = null;
    }

    pbPendingLoading.setVisibility(View.VISIBLE);
    cs.getAllBillPays(fromCache).observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<List<BillPay>>() {
                @Override
                public void onCompleted() {
                    if (progressDialog != null) {
                        progressDialog.dismiss();
                    }
                }

                @Override
                public void onError(Throwable e) {
                    if (progressDialog != null) {
                        progressDialog.dismiss();
                    }
                }

                @Override
                public void onNext(List<BillPay> billPays) {
                    pbPendingLoading.setVisibility(View.GONE);

                    Collections.sort(billPays, new Comparator<BillPay>() {
                        @Override
                        public int compare(BillPay lhs, BillPay rhs) {
                            return lhs.getSortOrder() < rhs.getSortOrder() ? -1
                                    : (lhs.getSortOrder() == rhs.getSortOrder() ? 0 : 1);
                        }
                    });

                    pendingBillsAdapter = new PendingBillsAdapter(getActivity(), billPays);
                    lvPending.setAdapter(pendingBillsAdapter);
                    finishActionMode();
                }
            });
}

From source file:com.doplgangr.secrecy.views.FilesListFragment.java

void changePassphraseInBackground(final String oldPassphrase, final String newPassphrase,
        final String confirmNewPassphrase, final ProgressDialog progressDialog) {
    new Thread(new Runnable() {
        public void run() {
            if (newPassphrase.length() == 0) {
                progressDialog.dismiss();
                Util.alert(context, CustomApp.context.getString(R.string.Error__change_password_failed),
                        CustomApp.context.getString(R.string.Error__password_empty_message),
                        Util.emptyClickListener, null);
                return;
            }/*  w w  w.  java 2s . c  o m*/
            if (!newPassphrase.equals(confirmNewPassphrase)) {
                progressDialog.dismiss();
                Util.alert(context, CustomApp.context.getString(R.string.Error__change_password_failed),
                        CustomApp.context.getString(R.string.Error__password_no_match_message),
                        Util.emptyClickListener, null);
                return;
            }
            if (!secret.changePassphrase(oldPassphrase, newPassphrase)) {
                progressDialog.dismiss();
                Util.alert(context, CustomApp.context.getString(R.string.Error__change_password_failed),
                        CustomApp.context.getString(R.string.Error__change_password_failed_message),
                        Util.emptyClickListener, null);
            } else {
                Util.alert(context, CustomApp.context.getString(R.string.Vault__change_password_ok),
                        CustomApp.context.getString(R.string.Vault__change_password_ok_message),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                context.finish();
                            }
                        });
            }
            progressDialog.dismiss();
        }
    }).start();
}

From source file:com.doplgangr.secrecy.views.VaultsListFragment.java

void createVaultInBackground(final String name, final String password, final File directory,
        final DialogInterface dialog, final ProgressDialog progressDialog) {
    new Thread(new Runnable() {
        @Override//from   www  . ja v  a 2s  . c om
        public void run() {
            VaultHolder.getInstance().createAndRetrieveVault(name, password);
            try {
                File file = new File(directory + "/.nomedia");
                file.delete();
                file.createNewFile();
                refresh();
            } catch (IOException e) {
                e.printStackTrace();
            }
            dialog.dismiss();
            progressDialog.dismiss();
        }
    }).start();
}

From source file:com.fortysevendeg.labs.bbc.rest.android.activities.BeerActivity.java

/**
 * Update beer on server/*from  w  ww  . ja v  a  2s . c o  m*/
 */
private void updateBeer() {
    if (TextUtils.isEmpty(etAlcohol.getText().toString()) || TextUtils.isEmpty(etName.getText().toString())) {
        Toast.makeText(BeerActivity.this, R.string.fieldsEmpty, Toast.LENGTH_SHORT).show();
        return;
    }
    final ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setMessage(getString(R.string.connecting));
    progressDialog.setIndeterminate(true);
    progressDialog.setCancelable(false);
    progressDialog.show();

    BeerRequest beerRequest = new BeerRequest();
    beerRequest.setAvb(Double.parseDouble(etAlcohol.getText().toString()));
    beerRequest.setName(etName.getText().toString());
    beerRequest.setDescription(etDescription.getText().toString());
    APIService.get().updateBeer(beerResponseEdit.getId(), beerRequest,
            new ContextAwareAPIDelegate<BeerResponse>(this, BeerResponse.class) {
                @Override
                public void onResults(BeerResponse beerResponse) {
                    progressDialog.dismiss();
                    Toast.makeText(BeerActivity.this, R.string.beerSaved, Toast.LENGTH_SHORT).show();
                    setResult(RESULT_OK);
                    finish();
                }

                @Override
                public void onError(Throwable e) {
                    progressDialog.dismiss();
                    Toast.makeText(BeerActivity.this, R.string.error, Toast.LENGTH_SHORT).show();
                }
            });
}

From source file:com.lnpdit.chatuidemo.activity.ContactlistFragment.java

/**
 * ?//from   ww  w . j a va  2  s.c o m
 * 
 * @param toDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("...");
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                CydlApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), ": " + e.getMessage(), 1).show();
                    }
                });

            }

        }
    }).start();

}

From source file:com.runye.express.chat.activity.ContactlistFragment.java

/**
 * ?//  w  ww .j  a v  a  2s.  c  o m
 * 
 * @param toDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("...");
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                MyApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), ": " + e.getMessage(), 1).show();
                    }
                });

            }

        }
    }).start();

}

From source file:com.example.android.foodrecipes.app.RecipeDetailsFragment.java

private void removeCurrentRecipeFromFavorites() {
    String title = getActivity().getString(R.string.text_please_wait);
    String text = getActivity().getString(R.string.text_removing_from_favorites);

    final ProgressDialog dialog = ProgressDialog.show(getActivity(), title, text);
    dialog.show();/*from   w  w  w  .jav  a2s.c  o  m*/

    final AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            String where = RecipeContract.RecipeEntry.COLUMN_EXTERNAL_ID + "=?";
            String[] selectionArgs = new String[] { String.valueOf(mRecipe.getExternalId()) };
            getActivity().getContentResolver().delete(CONTENT_URI, where, selectionArgs);
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            dialog.dismiss();
            Toast.makeText(getActivity(), getActivity().getString(R.string.recipe_removed_from_favorites),
                    Toast.LENGTH_SHORT).show();

            if (!mTwoPane) {
                // if we operate in the two pane mode we should not finish the activity as
                // we have only one activity, but with two fragments inside
                getActivity().finish();
            }
        }
    };

    dialog.setOnKeyListener(new Dialog.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialogInterface, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                task.cancel(true);
                dialog.dismiss();
            }
            return true;
        }
    });

    task.execute();
}

From source file:niltor.net.chatuidemo.activity.ContactlistFragment.java

/**
 * ?/*from w  w  w .j  a  v  a2 s.c  o  m*/
 * 
 * @param 'toDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("...");
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                DemoApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), ": " + e.getMessage(), Toast.LENGTH_SHORT)
                                .show();
                    }
                });

            }

        }
    }).start();

}