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:com.pentacog.mctracker.MCServerTrackerActivity.java

/**
 * Performs request for data from the server
 * @param server Server object to populate with data
 *//*from   w w  w  . j  a  v  a 2s  .  c o  m*/
private void getServerData(Server server) {
    final ProgressDialog dialog = ProgressDialog.show(this, "", "Requesting Server Info", true);
    GetServerDataTask task = new GetServerDataTask(server, new GetServerDataTask.ServerDataResultHandler() {

        @SuppressWarnings("unchecked")
        @Override
        public void onServerDataResult(final Server server, String result) {
            dialog.dismiss();
            if (result == null) {
                serverList.add(server);
                new SaveServerListTask(getApplicationContext()).execute(serverList.getServerList());
                updateListView();
            } else {
                AlertDialog.Builder builder = new AlertDialog.Builder(MCServerTrackerActivity.this);
                builder.setMessage("Failed to contact server\n" + result);
                builder.setPositiveButton("Try Again", new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        getServerData(server);
                    }
                });
                builder.setNegativeButton("Cancel", new OnClickListener() {

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

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        Intent addServer = new Intent(MCServerTrackerActivity.this, AddServerActivity.class);
                        addServer.putExtra(Server.SERVER_ID, server.id);
                        addServer.putExtra(Server.SERVER_NAME, server.name);
                        addServer.putExtra(Server.SERVER_ADDRESS, server.address);
                        addServer.putExtra(Server.SERVER_PORT, "" + server.port);

                        startActivityForResult(addServer, AddServerActivity.ADD_SERVER_ACTIVITY_ID);
                    }
                });

                builder.create().show();
            }
        }
    });

    task.execute();
}

From source file:com.xuejian.client.lxp.module.toolbox.im.ContactlistFragment.java

/**
 * user???/*from   w ww .  ja  v  a  2 s  .  co m*/
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("???...");
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, true);
                if (isAdded())
                    getActivity().runOnUiThread(new Runnable() {
                        public void run() {
                            pd.dismiss();
                            //                     Toast.makeText(getActivity(), "????", Toast.LENGTH_SHORT).show();
                            ToastUtil.getInstance(getActivity()).showToast("?");
                        }
                    });
            } catch (EaseMobException e) {
                e.printStackTrace();
                if (isAdded())
                    getActivity().runOnUiThread(new Runnable() {
                        public void run() {
                            pd.dismiss();
                            //                     Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT).show();
                            ToastUtil.getInstance(getActivity()).showToast("~??");
                        }
                    });
            }
        }
    }).start();

}

From source file:com.gmail.charleszq.picorner.ui.MainSlideMenuActivity.java

/**
 * When first time this activity starts, load default photo list, now it's
 * flickr interesting photos./*from  w  w  w .  j av a2s  .  co m*/
 */
void loadDefaultPhotoList() {
    MessageBus.reset();
    mCommand = getDefaultCommand();
    final ProgressDialog dialog = ProgressDialog.show(this, "", getString(R.string.loading_photos)); //$NON-NLS-1$
    dialog.setCancelable(true);
    mCommand.setCommndDoneListener(new ICommandDoneListener<MediaObjectCollection>() {

        @Override
        public void onCommandDone(ICommand<MediaObjectCollection> command, MediaObjectCollection t) {
            MainSlideMenuActivity.this.onCommandDone(command, t);
            if (dialog != null && dialog.isShowing()) {
                try {
                    dialog.dismiss();
                } catch (Exception ex) {

                }
            }
        }
    });
    mCommand.execute();
}

From source file:com.example.sujit.myapplication.Get_Taxi.java

private void showProfile() {
    LayoutInflater li = LayoutInflater.from(this);
    //Creating a view to get the dialog box
    View confirmDialog = li.inflate(R.layout.dialog_profile, null);
    buttonCall = (AppCompatButton) confirmDialog.findViewById(R.id.buttonCall);
    textViewName1 = (TextView) confirmDialog.findViewById(R.id.textViewName1);
    textViewLicenseNo1 = (TextView) confirmDialog.findViewById(R.id.textViewLicenseNo1);
    textViewAddress1 = (TextView) confirmDialog.findViewById(R.id.textViewAddress1);
    textViewMobile1 = (TextView) confirmDialog.findViewById(R.id.textViewMobile1);
    textViewTaxiNo1 = (TextView) confirmDialog.findViewById(R.id.textViewTaxiNo1);

    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    //Adding our dialog box to the view of alert dialog
    alert.setView(confirmDialog);//  w w  w  . j a  va2  s .c  o  m

    //Creating an alert dialog
    final AlertDialog alertDialog = alert.create();

    //Displaying the alert dialog

    RequestQueue requestQueue = Volley.newRequestQueue(Get_Taxi.this);
    final ProgressDialog loading = ProgressDialog.show(this, "Getting Route", "Please wait...", false, false);

    StringRequest stringRequest = new StringRequest(Request.Method.POST, "", new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            loading.dismiss();
            try {
                JSONObject jsonObject = new JSONObject(response);
                JSONArray jsonArray = jsonObject.getJSONArray("drivers");
                JSONObject jsonObject1 = jsonArray.getJSONObject(0);

                textViewName1.setText(jsonObject1.getString("full_name"));
                textViewLicenseNo1.setText(jsonObject1.getString("license_number"));
                textViewAddress1.setText(jsonObject1.getString("address"));
                textViewMobile1.setText(jsonObject1.getString("mobile_number"));
                textViewTaxiNo1.setText(jsonObject1.getString("taxi_number"));
                alertDialog.show();

            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            loading.dismiss();
        }
    }) {
        @Override
        protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<>();
            params.put("latitude", String.valueOf(currentLatitude));
            params.put("longitude", String.valueOf(currentLongitude));

            return params;

        }

    };
    requestQueue.add(stringRequest);
    buttonCall.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            alertDialog.dismiss();
        }
    });
}

From source file:uk.ac.horizon.artcodes.activity.ExperienceEditActivity.java

public void saveExperience(View view) {
    final Experience experience = getExperience();
    final boolean isNew = experience.getId() == null;
    final Activity activity = this;
    final ProgressDialog dialog = ProgressDialog.show(activity,
            getResources().getString(R.string.saving_progress_dialog_title),
            getResources().getString(R.string.saving_progress_dialog_message), true);
    getAccount().saveExperience(experience, new Account.AccountProcessCallback() {
        @Override/*from ww w . j  a v a2s . c  o  m*/
        public void accountProcessCallback(boolean success, Experience savedExperience) {
            dialog.dismiss();
            if (success) {
                if (isNew) {
                    Intent intent = ExperienceActivity.intent(activity, savedExperience);
                    startActivity(intent);
                    activity.finish();
                } else {
                    NavUtils.navigateUpTo(activity, ExperienceActivity.intent(activity, experience));
                }
            } else {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        new AlertDialog.Builder(activity).setTitle(R.string.saving_error_title)
                                .setMessage(R.string.saving_error_message).setPositiveButton(
                                        R.string.saving_error_button, new DialogInterface.OnClickListener() {
                                            public void onClick(DialogInterface dialog, int which) {
                                                dialog.dismiss();
                                            }
                                        })
                                .show();
                    }
                });
            }
        }
    });
}

From source file:org.messic.android.controllers.LoginController.java

public void login(final Activity context, final boolean remember, final String username, final String password,
        final ProgressDialog pd) throws Exception {
    Network.nukeNetwork();//www  .  j av a  2s  .  com

    final String baseURL = Configuration.getBaseUrl() + "/messiclogin";
    MultiValueMap<String, Object> formData = new LinkedMultiValueMap<String, Object>();
    formData.add("j_username", username);
    formData.add("j_password", password);
    try {
        RestJSONClient.post(baseURL, formData, MDMLogin.class, new RestJSONClient.RestListener<MDMLogin>() {
            public void response(MDMLogin response) {
                MessicPreferences mp = new MessicPreferences(context);
                mp.setRemember(remember, username, password);
                Configuration.setToken(response.getMessic_token());

                pd.dismiss();
                Intent ssa = new Intent(context, BaseActivity.class);
                context.startActivity(ssa);
            }

            public void fail(Exception e) {
                Log.e("Login", e.getMessage(), e);
                context.runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();
                    }
                });

            }
        });
    } catch (Exception e) {
        pd.dismiss();
        Log.e("login", e.getMessage(), e);
        throw e;
    }
}

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

/**
 * user???// w w w.  jav  a 2  s.c o m
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("???...");
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, true);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), "????", 0).show();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), "???", 0).show();
                    }
                });
            }
        }
    }).start();

}

From source file:com.softminds.matrixcalculator.OperationFragments.InverseFragment.java

public void RunAndGetDeterminantWithAdjoint(final int i, final ProgressDialog progressDialog) {
    Runnable runnable = new Runnable() {
        @Override//ww  w  .  j a  v a 2 s .  co m
        public void run() {
            Message message = new Message();
            Bundle bundle = new Bundle();
            float detr = (float) SquareList.get(i).getDeterminant(progressDialog);
            if (detr == 0.0f) {
                myHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getContext(), R.string.NoInverse, Toast.LENGTH_SHORT).show();
                    }
                }, 0);
                progressDialog.dismiss();
            } else {
                progressDialog.setProgress(0);
                bundle.putFloat("DETERMINANT", detr);
                MatrixV2 res = SquareList.get(i).getAdjoint(progressDialog);
                bundle.putAll(res.getDataBundled());
                message.setData(bundle);
                myHandler.sendMessage(message);
            }

        }
    };
    Thread thread = new Thread(runnable);
    thread.start();
}

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

/**
 * user???//  w w  w .  jav a2 s. c om
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("???...");
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), "????", Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}

From source file:com.dong.huang.imdemo.ui.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);//from w w w. jav a  2  s.com
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    DemoHelper.getInstance().logout(false, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // ??
                    ((MainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));

                }
            });
        }

        @Override
        public void onProgress(int progress, String status) {

        }

        @Override
        public void onError(int code, String message) {
            getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    pd.dismiss();
                    Toast.makeText(getActivity(), "unbind devicetokens failed", Toast.LENGTH_SHORT).show();

                }
            });
        }
    });
}