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.mobicage.rogerthat.registration.AbstractRegistrationActivity.java

public void registerDevice() {
    T.UI();//from w w w. j a  v a2 s .c o  m
    final HttpClient httpClient = HTTPUtil.getHttpClient();
    final String email = mWizard.getEmail();
    final String tosAge = mWizard.getTOSAge();
    final String pushNotifcationsEnabled = mWizard.getPushNotificationEnabled();
    final String timestamp = "" + mWizard.getTimestamp();
    final String deviceId = mWizard.getDeviceId();
    final String registrationId = mWizard.getRegistrationId();
    // Make call to Rogerthat
    String message = getString(R.string.activating);
    final ProgressDialog progressDialog = UIUtils.showProgressDialog(mActivity, null, message, true, false);
    final SafeRunnable showErrorDialog = new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            T.UI();
            progressDialog.dismiss();
            UIUtils.showErrorPleaseRetryDialog(mActivity);
        }
    };

    runOnWorker(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            T.REGISTRATION();
            String version = "3";
            String signature = SecurityUtils.sha256(version + " " + email + " " + timestamp + " " + deviceId
                    + " " + registrationId + " " + CloudConstants.REGISTRATION_MAIN_SIGNATURE);

            HttpPost httppost = HTTPUtil.getHttpPost(mActivity,
                    CloudConstants.REGISTRATION_REGISTER_DEVICE_URL);
            try {
                List<NameValuePair> nameValuePairs = HTTPUtil.getRegistrationFormParams(mActivity);
                nameValuePairs.add(new BasicNameValuePair("version", version));
                nameValuePairs.add(new BasicNameValuePair("registration_time", timestamp));
                nameValuePairs.add(new BasicNameValuePair("device_id", deviceId));
                nameValuePairs.add(new BasicNameValuePair("registration_id", registrationId));
                nameValuePairs.add(new BasicNameValuePair("signature", signature));
                nameValuePairs.add(new BasicNameValuePair("email", email));
                nameValuePairs.add(new BasicNameValuePair("tos_age", tosAge));
                nameValuePairs
                        .add(new BasicNameValuePair("push_notifications_enabled", pushNotifcationsEnabled));
                nameValuePairs.add(new BasicNameValuePair("GCM_registration_id", getGCMRegistrationId()));
                nameValuePairs.add(new BasicNameValuePair("hardware_model", SystemPlugin.getDeviceModelName()));
                TelephonyManager telephonyManager = (TelephonyManager) mService
                        .getSystemService(Context.TELEPHONY_SERVICE);
                if (telephonyManager != null) {
                    nameValuePairs.add(
                            new BasicNameValuePair("sim_carrier_name", telephonyManager.getSimOperatorName()));
                }

                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                // Execute HTTP Post Request
                HttpResponse response = httpClient.execute(httppost);

                int statusCode = response.getStatusLine().getStatusCode();
                HttpEntity entity = response.getEntity();

                if (entity == null) {
                    runOnUI(showErrorDialog);
                    return;
                }

                @SuppressWarnings("unchecked")
                final Map<String, Object> responseMap = (Map<String, Object>) JSONValue
                        .parse(new InputStreamReader(entity.getContent()));

                if (statusCode != 200 || responseMap == null) {
                    if (statusCode == 500 && responseMap != null) {
                        final String errorMessage = (String) responseMap.get("error");
                        if (errorMessage != null) {
                            runOnUI(new SafeRunnable() {
                                @Override
                                protected void safeRun() throws Exception {
                                    T.UI();
                                    progressDialog.dismiss();
                                    UIUtils.showDialog(mActivity, null, errorMessage);
                                }
                            });
                            return;
                        }
                    }
                    runOnUI(showErrorDialog);
                    return;
                }
                JSONObject account = (JSONObject) responseMap.get("account");
                setAgeAndGenderSet((Boolean) responseMap.get("age_and_gender_set"));

                final RegistrationInfo info = new RegistrationInfo(email,
                        new Credentials((String) account.get("account"), (String) account.get("password")));
                runOnUI(new SafeRunnable() {
                    @Override
                    protected void safeRun() throws Exception {
                        T.UI();
                        mWizard.setEmail(email);
                        mWizard.save();
                        tryConnect(progressDialog, 1, getString(R.string.registration_establish_connection,
                                email, getString(R.string.app_name)) + " ", info);
                    }
                });

            } catch (Exception e) {
                L.d(e);
                runOnUI(showErrorDialog);
            }
        }
    });
}

From source file:cn.ucai.superwechat.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  ww.ja  v a 2 s.com*/
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    SuperWeChatHelper.getInstance().logout(false, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // show login screen
                    ((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();
                }
            });
        }
    });
}

From source file:org.protocoder.appApi.ProtoScripts.java

public void shareProtoFileDialog(String folder, String name) {
    final ProgressDialog progress = new ProgressDialog(mProtocoder.a);
    progress.setTitle("Exporting .proto");
    progress.setMessage("Your project will be ready soon!");
    progress.setCancelable(true);//from  w  ww  . j  ava 2s. c  om
    progress.setCanceledOnTouchOutside(false);
    progress.show();

    String zipFilePath = exportProto(folder, name);

    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(zipFilePath)));
    shareIntent.setType("application/zip");

    progress.dismiss();

    mProtocoder.a.startActivity(
            Intent.createChooser(shareIntent, mProtocoder.a.getResources().getText(R.string.share_proto_file)));
}

From source file:cn.ucai.superwechat.fragment.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(cn.ucai.superwechat.R.string.Are_logged_out);
    pd.setMessage(st);//from  ww  w .  ja  v  a  2s . c o  m
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    superWeChatApplication instance = superWeChatApplication.getInstance();
                    instance.getContactList().clear();
                    instance.getGroupList().clear();
                    instance.getPublicGroupList().clear();
                    instance.getUserList().clear();
                    // ??
                    ((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();

                }
            });
        }
    });
}

From source file:com.grass.caishi.cc.frag.FriendsListFragment.java

/**
 * user???//from ww  w.  ja  v a2 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.grass.caishi.cc.activity.main.FriendsListFragment.java

/**
 * user???/*from  w  w w . j ava2s  .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);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), "????", Toast.LENGTH_SHORT).show();
                    }
                });
            } 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.imalu.alyou.activity.FriendlistFragment.java

/**
 * user???//from  ww  w.j a va 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,false);
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    Toast.makeText(getActivity(), "????", 0).show();
                    //refresh();
                }
            });
            //} 
            //            catch (EaseMobException e) {
            //               e.printStackTrace();
            //               getActivity().runOnUiThread(new Runnable() {
            //                  public void run() {
            //                     pd.dismiss();
            //                     Toast.makeText(getActivity(), "???", 0).show();
            //                  }
            //               });
            //            }
        }
    }).start();

}

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

public void deleteExperience(View view) {
    final Activity activity = this;
    new AlertDialog.Builder(this)
            .setMessage(getString(R.string.experienceDeleteConfirm, getExperience().getName()))
            .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    final ProgressDialog progressDialog = ProgressDialog.show(activity,
                            getResources().getString(R.string.delete_progress_dialog_title),
                            getResources().getString(R.string.delete_progress_dialog_message), true);

                    getAccount().deleteExperience(getExperience(), new Account.AccountProcessCallback() {
                        @Override
                        public void accountProcessCallback(boolean success, Experience experience) {
                            progressDialog.dismiss();
                            if (success) {
                                NavUtils.navigateUpTo(ExperienceEditActivity.this,
                                        new Intent(ExperienceEditActivity.this, NavigationActivity.class));
                            } else {
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        new AlertDialog.Builder(activity).setTitle(R.string.delete_error_title)
                                                .setMessage(R.string.delete_error_message)
                                                .setPositiveButton(R.string.delete_error_button,
                                                        new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog,
                                                                    int which) {
                                                                dialog.dismiss();
                                                            }
                                                        })
                                                .show();
                                    }//  ww w.j ava  2  s  .  c  om
                                });
                            }
                        }
                    });
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}

From source file:org.cafemember.messenger.mytg.fragments.TransfareActivity.java

private void saveName() {
    if (!checkUserName(phoneField.getText().toString(), true)) {
        return;//  w  w w  . j  a  va2s.com
    }
    if (getContext() == null) {
        return;
    }
    String newName = phoneField.getText().toString();
    String amount = amountField.getText().toString();

    if (amount == null || amount.length() == 0) {
        showErrorAlert("    ");
        return;
    }
    int amountInt;
    try {
        amountInt = Integer.parseInt(amount);
    } catch (Exception e) {
        showErrorAlert("    ");
        return;
    }
    if (amountInt < 100) {
        showErrorAlert("     100 ");
        return;
    }
    int transfareType = 1;
    /*if(typeJoin.isChecked()){
    transfareType = 1;
    }
    else if(typeView.isChecked()){
    transfareType = 2;
    }*/
    final ProgressDialog progressDialog = new ProgressDialog(getContext());
    progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
    progressDialog.setCanceledOnTouchOutside(false);
    //        progressDialog.setCancelable(false);
    progressDialog.show();
    Commands.transfare(newName, amountInt, transfareType, new OnResponseReadyListener() {
        @Override
        public void OnResponseReady(boolean error, JSONObject data, String message) {
            progressDialog.dismiss();
            if (error) {
                showErrorAlert(message);
            } else {
                Toast.makeText(context, "  ?  ", Toast.LENGTH_SHORT)
                        .show();
                //                    finishFragment();
            }
        }
    });
}

From source file:com.imalu.alyou.activity.RegisterActivity.java

/**
 * /*from   w w  w.ja v a  2s .c  o  m*/
 * 
 * @param view
 */
public void register(View view) {

    final String pwd = passwordEditText.getText().toString().trim();
    String confirm_pwd = confirmPwdEditText.getText().toString().trim();
    if (TextUtils.isEmpty(pwd)) {
        Toast.makeText(this, "???", Toast.LENGTH_SHORT).show();
        passwordEditText.requestFocus();
        return;
    } else if (TextUtils.isEmpty(confirm_pwd)) {
        Toast.makeText(this, "???", Toast.LENGTH_SHORT).show();
        confirmPwdEditText.requestFocus();
        return;
    } else if (!pwd.equals(confirm_pwd)) {
        Toast.makeText(this, "????", Toast.LENGTH_SHORT).show();
        return;
    }

    RegisterRequest registerReq = new RegisterRequest();

    registerReq.setPassword(pwd);
    registerReq.setUsername(username);
    NetManager.execute(NetManager.REGISTER_REQUEST_OPERATION, registerReq, new JsonHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            //pd.dismiss();
            Log.e("login_check", " response:" + response.toString());
            //Toast.makeText(getApplicationContext(), ": " + , 0).show();

            //RegisterResponse regResp = (RegisterResponse)response;

            // ?????
            //AlUApplication.getInstance().setUserName(username);
            //AlUApplication.getInstance().setPassword(password);

            /*runOnUiThread(new Runnable() {
               public void run() {
                  pd.setMessage("???...");
               }
            });*/
            try {

                RegisterResponse regResp = new RegisterResponse();
                regResp.setJsonObject(response);
                Log.e("AAAAAAAAAA", "" + regResp.getCode());
                if (regResp.getCode()) {
                    Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getApplicationContext(), ": " + regResp.getInfo(),
                            Toast.LENGTH_SHORT).show();
                }
                // ** ?logout??
                // ** manually load all local groups and
                // conversations in case we are auto login
                //EMGroupManager.getInstance().loadAllGroups();
                //EMChatManager.getInstance().loadAllConversations();

                // demo??????username??
                /*List<String> usernames = EMContactManager.getInstance().getContactUserNames();
                EMLog.d("roster", "contacts size: " + usernames.size());
                        
                for (String username : usernames) {
                   User user = new User();
                   user.setUsername(username);
                   setUserHearder(username, user);
                   userlist.put(username, user);
                }*/
                /*Map<String, User> userlist = new HashMap<String, User>();
                // user""
                User newFriends = new User();
                newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME);
                newFriends.setNick("");
                newFriends.setHeader("");
                userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends);
                // "?"
                User groupUser = new User();
                groupUser.setUsername(Constant.GROUP_USERNAME);
                groupUser.setNick("?");
                groupUser.setHeader("");
                userlist.put(Constant.GROUP_USERNAME, groupUser);*/

                // 
                //AlUApplication.getInstance().setContactList(userlist);
                // db
                //UserDao dao = new UserDao(LoginActivity.this);
                //List<User> users = new ArrayList<User>(userlist.values());
                //dao.saveContactList(users);

                // ??(??groupidgroupname????members),sdkdb
                //EMGroupManager.getInstance().getGroupsFromServer();*/
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), ": " + e.getMessage(), Toast.LENGTH_SHORT)
                        .show();
                //e.printStackTrace();
            }

            Log.e("login_check", "1111111111111111111");
            //?nickname ios?nick
            //boolean updatenick = EMChatManager.getInstance().updateCurrentUserNick(AlUApplication.currentUserNick);
            //if (!updatenick) {
            //   EMLog.e("LoginActivity", "update current user nick fail");
            //}

            //if (!LoginActivity.this.isFinishing())
            //pd.dismiss();
            // ?
            startActivity(new Intent(RegisterActivity.this, LoginActivity.class));
            finish();
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject jsonObj) {
            //   Log.e("register", throwable.getMessage());
            finish();
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, final String responseString,
                Throwable throwable) {
            runOnUiThread(new Runnable() {
                public void run() {
                    //pd.dismiss();
                    //Toast.makeText(getApplicationContext(), ": " + responseString, 0).show();
                    Log.e("register", responseString);
                    finish();
                }
            });
        }
    });

    //
    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) {
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setMessage("...");
        pd.show();
        new Thread(new Runnable() {
            public void run() {
                try {
                    // sdk
                    EMChatManager.getInstance().createAccountOnServer(username, pwd);
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (!RegisterActivity.this.isFinishing())
                                pd.dismiss();
                            // ???
                            AlUApplication.getInstance().setUserName(username);
                            Toast.makeText(getApplicationContext(), "?", 0).show();
                            finish();
                        }
                    });
                } catch (final EaseMobException e) {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (!RegisterActivity.this.isFinishing())
                                pd.dismiss();
                            int errorCode = e.getErrorCode();
                            if (errorCode == EMError.NONETWORK_ERROR) {
                                Toast.makeText(getApplicationContext(), "?",
                                        Toast.LENGTH_SHORT).show();
                            } else if (errorCode == EMError.USER_ALREADY_EXISTS) {
                                Toast.makeText(getApplicationContext(), "?",
                                        Toast.LENGTH_SHORT).show();
                            } else if (errorCode == EMError.UNAUTHORIZED) {
                                Toast.makeText(getApplicationContext(), "???",
                                        Toast.LENGTH_SHORT).show();
                            } else {
                                Toast.makeText(getApplicationContext(), ": " + e.getMessage(),
                                        Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                }
            }
        }).start();

    }
    //
}