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:eu.dirtyharry.androidopsiadmin.Main.java

public void event_opsisenddepotconfigchanges() {
    final ProgressDialog dialog = ProgressDialog.show(Main.this, getString(R.string.gen_title_pleasewait),
            String.format(getString(R.string.pd_senddepotchangesfor), choosendepot), true);
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();
            if (!GlobalVar.getInstance().getError().equals("null")) {
                new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                        GlobalVar.getInstance().getError(), false);
            }/*from  w w w.  j av a 2s  .  c  o  m*/
        }
    };
    Thread checkUpdate = new Thread() {
        public void run() {
            Looper.prepare();
            JSONArray test = new JSONArray();
            JSONObject params = new JSONObject();
            try {
                params.put("id", choosendepot);
                params.put("type", "OpsiConfigserver");
                for (int i = 0; i < resultconfignames.size(); i++) {
                    params.put(resultconfignames.get(i), resultconfigvalues.get(i));
                }
            } catch (JSONException e1) {
                e1.printStackTrace();
            }

            test.put(params);
            opsiresult = new JSONObject();
            opsiresult = eu.dirtyharry.androidopsiadmin.Networking.opsiGetJSONObject("rpc", serverip,
                    serverport, "host_updateObject", test, serverusername, serverpasswd);
            try {
                if (!opsiresult.isNull("error")) {
                    GlobalVar.getInstance().setError(opsiresult.getString("error"));
                }

            } catch (JSONException e) {
                e.printStackTrace();
            }
            handler.sendEmptyMessage(0);
        }
    };
    checkUpdate.start();
}

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

private void getRecentRecipientsList(final int selItem, boolean fromCache) {
    final ProgressDialog progressDialog = ProgressDialog.show(this.getActivity(),
            getResources().getString(R.string.cashila), getResources().getString(R.string.cashila_fetching),
            true);/*from  w  w w .j  ava2s .  co  m*/

    // ensure login and get the list of all recipients
    cs.getBillPaysRecent(fromCache).observeOn(AndroidSchedulers.mainThread())
            // this must be an Observer (not a Action1), otherwise the error-propagation does not work
            .subscribe(new Observer<List<BillPayExistingRecipient>>() {
                @Override
                public void onCompleted() {
                    progressDialog.dismiss();
                }

                @Override
                public void onError(Throwable e) {
                    progressDialog.dismiss();
                }

                @Override
                public void onNext(List<BillPayExistingRecipient> listCashilaResponse) {
                    if (listCashilaResponse.size() == 0) {
                        Utils.showSimpleMessageDialog(getActivity(),
                                getResources().getString(R.string.cashila_no_recipients), new Runnable() {
                                    @Override
                                    public void run() {
                                        ((CashilaPaymentsActivity) getActivity()).openAddRecipient();

                                    }
                                });

                    } else {
                        recipientArrayAdapter = new RecipientArrayAdapter(getActivity(), listCashilaResponse);
                        spRecipients.setAdapter(recipientArrayAdapter);

                        // if we got a uuid to select the current recipient, sarch through the list, if we have it
                        // and select it
                        if (toSelect != null) {
                            int count = 0;
                            for (BillPayExistingRecipient recipient : listCashilaResponse) {
                                if (recipient.id.equals(toSelect.toString())) {
                                    spRecipients.setSelection(count);
                                    break;
                                }
                                count++;
                            }
                        } else {
                            spRecipients.setSelection(selItem);
                        }
                    }

                    // fetch account limits, if none are available
                    updateAccountLimits();
                }
            });
}

From source file:com.liwn.zzl.markbit.DrawOptionsMenuActivity.java

protected void loadBitmapFromUriAndRun(final Uri uri, final RunnableWithBitmap runnable) {
    String loadMessge = getResources().getString(R.string.dialog_load);
    final ProgressDialog dialog = ProgressDialog.show(DrawOptionsMenuActivity.this, "", loadMessge, true);

    Thread thread = new Thread("loadBitmapFromUriAndRun") {
        @Override//  w ww  .j av  a  2  s  .co  m
        public void run() {
            Bitmap bitmap = null;
            try {
                bitmap = FileIO.getBitmapFromUri(uri);
            } catch (Exception e) {
                loadBitmapFailed = true;
            }

            if (bitmap != null) {
                runnable.run(bitmap);
            } else {
                loadBitmapFailed = true;
            }
            dialog.dismiss();
            MarkBitApplication.currentTool.resetInternalState(StateChange.NEW_IMAGE_LOADED);
            if (loadBitmapFailed) {
                loadBitmapFailed = false;
                new InfoDialog(DialogType.WARNING, R.string.dialog_loading_image_failed_title,
                        R.string.dialog_loading_image_failed_text).show(getSupportFragmentManager(),
                                "loadbitmapdialogerror");
            } else {
                if (!(MarkBitApplication.currentTool instanceof ImportTool)) {
                    MarkBitApplication.savedPictureUri = uri;
                }
            }
        }
    };
    thread.start();
}

From source file:com.microsoft.live.sample.skydrive.SkyDriveActivity.java

private void loadFolder(String folderId) {
    assert folderId != null;
    mCurrentFolderId = folderId;// w w w .j a  va 2  s  . c o m

    final ProgressDialog progressDialog = ProgressDialog.show(this, "", "Loading. Please wait...", true);

    mClient.getAsync(folderId + "/files", new LiveOperationListener() {
        @Override
        public void onComplete(LiveOperation operation) {
            progressDialog.dismiss();

            JSONObject result = operation.getResult();
            if (result.has(JsonKeys.ERROR)) {
                JSONObject error = result.optJSONObject(JsonKeys.ERROR);
                String message = error.optString(JsonKeys.MESSAGE);
                String code = error.optString(JsonKeys.CODE);
                showToast(code + ": " + message);
                return;
            }

            ArrayList<SkyDriveObject> skyDriveObjs = mPhotoAdapter.getSkyDriveObjs();
            skyDriveObjs.clear();

            JSONArray data = result.optJSONArray(JsonKeys.DATA);
            for (int i = 0; i < data.length(); i++) {
                SkyDriveObject skyDriveObj = SkyDriveObject.create(data.optJSONObject(i));
                if (skyDriveObj != null) {
                    skyDriveObjs.add(skyDriveObj);
                }
            }

            mPhotoAdapter.notifyDataSetChanged();
        }

        @Override
        public void onError(LiveOperationException exception, LiveOperation operation) {
            progressDialog.dismiss();

            showToast(exception.getMessage());
        }
    });
}

From source file:com.einzig.ipst2.activities.MainActivity.java

/**
 * Parses emails for portals/*from  ww  w.j a  va  2 s . c o  m*/
 * <p>
 * Runs 3 tasks to:
 * <ol>
 * <li>Get OAuth token</li>
 * <li>Search for relevant emails</li>
 * <li>Parse portals from the relevant emails</li>
 * </ol>
 * </p>
 *
 * @param account GMail account
 * @param dialog  Progress dialog to display while authenticating and searching for mail
 */
private void parseEmailWork(Account account, final ProgressDialog dialog) {
    try {
        Logger.d("Showing DIALOG");
        String token = new AuthenticatorTask(this, account).execute().get();
        final MailBundle bundle = new GetMailTask(this, account, token).execute().get();
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    dialog.dismiss();
                    if (bundle != null)
                        new EmailParseTask(MainActivity.this, bundle).execute();
                    else {
                        gmail_login_button.setVisibility(View.VISIBLE);
                        progress_view_mainactivity.setVisibility(View.INVISIBLE);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    } catch (InterruptedException | ExecutionException e) {
        Logger.e(e.toString());
    }
}

From source file:com.ccxt.whl.activity.ContactlistFragment.java

/**
 * ?/*from www  .ja  va2 s.  c  om*/
 * 
 * @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(), 1).show();
                    }
                });

            }

        }
    }).start();

}

From source file:org.gdgsp.fragment.PeopleFragment.java

public void sendRaffle(final String dbDate) {
    final ProgressDialog progressDialog = ProgressDialog.show(activity, getString(R.string.app_name),
            getString(R.string.sending), false, false);
    progressDialog.show();/*from   w  w w .  j  a  v  a  2  s.c o  m*/

    Event event = (Event) activity.getIntent().getSerializableExtra("event");

    Ion.with(getContext()).load(Other.getRaffleUrl(activity, event.getId()))
            .setBodyParameter("app_key", Other.getAppKey()).setBodyParameter("raffle_date", dbDate)
            .setBodyParameter("seconds", String.valueOf(count))
            .setBodyParameter("refresh_token", Other.getRefreshToken(activity)).asString()
            .setCallback(new FutureCallback<String>() {
                @Override
                public void onCompleted(Exception e, String response) {
                    progressDialog.dismiss();

                    if (e != null) {
                        AlertDialog alertDialog = new AlertDialog.Builder(activity)
                                .setTitle(getString(R.string.connection_error))
                                .setMessage(getString(R.string.login_error_sub))
                                .setPositiveButton(getString(R.string.yes),
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface p1, int p2) {
                                                sendRaffle(dbDate);
                                            }
                                        })
                                .setNegativeButton(getString(R.string.no), null)

                                .create();

                        alertDialog.setCanceledOnTouchOutside(false);
                        alertDialog.show();
                        e.printStackTrace();
                        return;
                    }

                    if (response.matches("success|invalid_user|invalid_key")) {
                        String message = "";

                        switch (response) {
                        case "success":
                            message = getString(R.string.raffle_success);
                            break;
                        case "invalid_user":
                            message = getString(R.string.notification_invalid_user);
                            break;
                        case "invalid_key":
                            message = getString(R.string.invalid_key);
                            break;
                        }

                        Other.showToast(activity, message);
                    }
                }
            });
}

From source file:com.nxt.njitong.ContactlistActivity.java

/**
 * ?//from ww  w.j  a  v  a 2s  .c o  m
 *
 * @param
 */
public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(context);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(context);
                dao.deleteContact(tobeDeleteUser.getUsername());
                DemoApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

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

            }

        }
    }).start();

}

From source file:com.nxt.njitong.ContactlistActivity.java

/**
 * user???/*from   ww  w.jav a 2s .c  o m*/
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(context);
    String st1 = getResources().getString(R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(context, st2, Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(context, st3, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}

From source file:com.safeness.im.activity.ContactlistFragment.java

/**
 * ?//w  ww  . ja  v a  2s. c o m
 * 
 * @param
 */
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());
                PatientApplication.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();

}