List of usage examples for android.app ProgressDialog setOnCancelListener
public void setOnCancelListener(@Nullable OnCancelListener listener)
From source file:com.example.levelup.core.app.ProgressFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { ProgressDialog progressDialog = new ProgressDialog(getActivity()); progressDialog.setIndeterminate(true); progressDialog.setCancelable(mLoaderId != LOADER_ID_NOT_SPECIFIED); progressDialog.setTitle(mTitle);/*from ww w .j a v a 2 s . c o m*/ progressDialog.setMessage(getText(mMessage)); if (mLoaderId != LOADER_ID_NOT_SPECIFIED) { progressDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { getLoaderManager().destroyLoader(mLoaderId); } }); } return progressDialog; }
From source file:com.pixmob.r2droid.SelectAccountActivity.java
@Override protected Dialog onCreateDialog(int id) { if (AUTH_PENDING_DIALOG == id) { return new AlertDialog.Builder(this).setTitle(R.string.error).setMessage(R.string.auth_pending) .setIcon(R.drawable.alert_dialog_icon).create(); }//from w w w . j av a 2 s .c o m if (AUTH_ERROR_DIALOG == id) { return new AlertDialog.Builder(this).setTitle(R.string.error).setMessage(R.string.auth_failed_error) .setIcon(R.drawable.alert_dialog_icon).create(); } if (NETWORK_ERROR_DIALOG == id) { return new AlertDialog.Builder(this).setTitle(R.string.error).setMessage(R.string.network_error) .setIcon(R.drawable.alert_dialog_icon).create(); } if (PROGRESS_DIALOG == id) { final ProgressDialog d = new ProgressDialog(this); d.setTitle(R.string.please_wait); d.setMessage(getString(R.string.checking_account)); d.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { accountVerifier.cancel(true); accountVerifier = null; } }); return d; } return super.onCreateDialog(id); }
From source file:com.aibasis.parent.ui.entrance.LoginActivity.java
/** * /*from w w w. j a va2s .com*/ * * @param view */ public void login(View view) { if (!CommonUtils.isNetWorkConnected(this)) { Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show(); return; } currentUsername = usernameEditText.getText().toString().trim(); currentPassword = passwordEditText.getText().toString().trim(); if (TextUtils.isEmpty(currentUsername)) { Toast.makeText(this, R.string.User_name_cannot_be_empty, Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(currentPassword)) { Toast.makeText(this, R.string.Password_cannot_be_empty, Toast.LENGTH_SHORT).show(); return; } progressShow = true; final ProgressDialog pd = new ProgressDialog(LoginActivity.this); pd.setCanceledOnTouchOutside(false); pd.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { progressShow = false; } }); pd.setMessage(getString(R.string.Is_landing)); pd.show(); final long start = System.currentTimeMillis(); accountAPI.login(currentUsername, currentPassword, new RequestListener() { @Override public void onComplete(String result) { try { final LoginResult loginResult = LoginResult.parse(result); if (LoginResult.SUCCESS.equals(loginResult.getResult())) { // sdk?? EMChatManager.getInstance().login(loginResult.getEaseId(), loginResult.getEasePassword(), new EMCallBack() { @Override public void onSuccess() { if (!progressShow) { return; } // ????? DemoApplication.getInstance().setUserName(currentUsername); DemoApplication.getInstance().setPassword(currentPassword); DemoApplication.getInstance().setEaseId(loginResult.getEaseId()); DemoApplication.getInstance() .setEasePassword(loginResult.getEasePassword()); DemoApplication.getInstance().setParentId(loginResult.getParentId()); SharePreferenceUtil sharePreferenceUtil = new SharePreferenceUtil( LoginActivity.this); sharePreferenceUtil .setParentId(DemoApplication.getInstance().getParentId()); try { // ** ?logout??? // ** manually load all local groups and EMGroupManager.getInstance().loadAllGroups(); EMChatManager.getInstance().loadAllConversations(); // ?? initializeContacts(); } catch (Exception e) { e.printStackTrace(); // ????? runOnUiThread(new Runnable() { public void run() { pd.dismiss(); DemoHXSDKHelper.getInstance().logout(true, null); Toast.makeText(getApplicationContext(), R.string.login_failure_failed, Toast.LENGTH_SHORT) .show(); } }); return; } // ?nickname ios?nick boolean updatenick = EMChatManager.getInstance() .updateCurrentUserNick(DemoApplication.currentUserNick.trim()); if (!updatenick) { Log.e("LoginActivity", "update current user nick fail"); } if (!LoginActivity.this.isFinishing() && pd.isShowing()) { pd.dismiss(); } // ? Intent intent = new Intent(LoginActivity.this, MainActivity.class); startActivity(intent); finish(); } @Override public void onProgress(int progress, String status) { } @Override public void onError(final int code, final String message) { if (!progressShow) { return; } runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getApplicationContext(), getString(R.string.Login_failed) + message, Toast.LENGTH_SHORT).show(); } }); } }); } else if (LoginResult.FAILED.equals(loginResult.getResult())) { { Toast.makeText(getApplicationContext(), getString(R.string.Login_failed), Toast.LENGTH_SHORT).show(); } } } catch (JSONException e) { e.printStackTrace(); } } @Override public void onAPIException(APIException exception) { } }); }
From source file:com.ubuntuone.android.files.activity.StoreActivity.java
/** * Builds a "logging in" progress dialog. If user cancels, the activity * finishes.//www . j av a2s . c om * * @return a dialog indicating logging in */ private Dialog buildLoggingInDialog() { final ProgressDialog dialog = buildSimpleProgressDialog(R.string.progress_signing_in); dialog.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { if (mLoginTask != null) { mLoginTask.cancel(true); } } }); dialog.setCancelable(true); return dialog; }
From source file:org.xwiki.android.authenticator.auth.AuthenticatorActivity.java
public void showProgress(CharSequence message, final AsyncTask asyncTask) { // To avoid repeatedly create if (mProgressDialog != null && mProgressDialog.isShowing()) { return;//from w w w . java2s . c o m } final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(message); dialog.setIndeterminate(true); dialog.setCancelable(true); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.i(TAG, "user cancelling authentication"); if (asyncTask != null) { asyncTask.cancel(true); } } }); // We save off the progress dialog in a field so that we can dismiss // it later. mProgressDialog = dialog; mProgressDialog.show(); }
From source file:org.klnusbaum.udj.auth.AuthActivity.java
@Override protected Dialog onCreateDialog(int id) { final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getText(R.string.authenticating)); dialog.setIndeterminate(true);// ww w. j a v a 2s . co m dialog.setCancelable(true); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.i(TAG, "user cancelling authentication"); if (mAuthTask != null) { mAuthTask.cancel(true); } } }); // We save off the progress dialog in a field so that we can dismiss // it later. We can't just call dismissDialog(0) because the system // can lose track of our dialog if there's an orientation change. mProgressDialog = dialog; return dialog; }
From source file:org.mythdroid.activities.MDActivity.java
@Override public Dialog onCreateDialog(int id) { switch (id) { case FRONTEND_CHOOSER: final Dialog d = createFrontendDialog(); d.setOnDismissListener(dismissListener); d.setOnCancelListener(cancelListener); return d; case DIALOG_LOAD: final ProgressDialog prog = new ProgressDialog(this); prog.setIndeterminate(true);/*w w w. j a va2 s . c o m*/ prog.setMessage(getResources().getText(R.string.loading)); prog.setCanceledOnTouchOutside(false); prog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { finish(); } }); return prog; } return null; }
From source file:com.listapp.ListappActivity.java
@Override protected Dialog onCreateDialog(int id) { super.onCreateDialog(id); switch (id) { case ERR_DIALOG: AlertDialog errDialog = new AlertDialog.Builder(this) // See // http://code.google.com/p/android/issues/detail?id=6489 .setMessage("").setCancelable(false).setNeutralButton("OK", new OnClickListener() { @Override// w ww. j ava 2 s . c o m public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).create(); return errDialog; case LOADING_DIALOG: ProgressDialog progressDialog = new ProgressDialog(mContext); progressDialog.setMessage("Loading..."); progressDialog.setCancelable(true); progressDialog.setCanceledOnTouchOutside(false); // Listen for back button or cancel button in dialog itself progressDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (taskInProgress != null) { // TODO why doesn't this stop the HTTP request? taskInProgress.cancel(true); } } }); return progressDialog; default: return null; } }
From source file:com.clearcenter.mobile_demo.mdAuthenticatorActivity.java
protected Dialog onCreateDialog(int id) { final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getText(R.string.login_activity_authenticating)); dialog.setIndeterminate(true);//from ww w. j av a 2 s . c o m dialog.setCancelable(true); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.i(TAG, "user cancelling authentication"); if (auth_task != null) { auth_task.cancel(true); } } }); // We save off the progress dialog in a field so that we can dismiss // it later. We can't just call dismissDialog(0) because the system // can lose track of our dialog if there's an orientation change. progress_dialog = dialog; return dialog; }
From source file:com.imalu.alyou.activity.LoginActivity.java
/** * //from w ww. j a va 2 s . c o m * * @param view */ public void login(View view) { if (!CommonUtils.isNetWorkConnected(this)) { Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show(); return; } final String username = usernameEditText.getText().toString(); final String password = passwordEditText.getText().toString(); //AlUApplication.currentUserNick = usernameEditText.getText().toString(); if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)) { progressShow = true; final ProgressDialog pd = new ProgressDialog(LoginActivity.this); pd.setCanceledOnTouchOutside(false); pd.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { progressShow = false; } }); pd.setMessage("..."); pd.show(); LoginRequest loginReq = new LoginRequest(); loginReq.setUsername(username); loginReq.setPassword(password); NetManager.execute(NetManager.LOGIN_REQUEST_OPERATION, loginReq, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { try { pd.dismiss(); Log.e("login_check", " response:" + response.toString()); UserInfo userInfo = new UserInfo(); userInfo.setJsonObject(response); AlUApplication.getMyInfo().setPhoneNum(username); AlUApplication.getMyInfo().setPassword(password); AlUApplication.getMyInfo().setHxname(userInfo.getHXName()); AlUApplication.getMyInfo().setId(userInfo.getID()); AlUApplication.getMyInfo().setUsername(userInfo.getUserName()); AlUApplication.getMyInfo().setKey(userInfo.getKey()); AlUApplication.getMyInfo().setJifen(userInfo.getJifen()); AlUApplication.getMyInfo().setAge(userInfo.getAge()); AlUApplication.getMyInfo().setLocus(userInfo.getLocus()); AlUApplication.getMyInfo().setRealname(userInfo.getRealName()); AlUApplication.getMyInfo().setSex(userInfo.getSex()); AlUApplication.getMyInfo().setSocietykey(userInfo.getSocietyKey()); AlUApplication.getMyInfo().setJiarugonghuikey(userInfo.getJiaruGonghuiKey()); AlUApplication.getMyInfo().setSocietyName(userInfo.getSocietyName()); PersonalInfoResponse personal = new PersonalInfoResponse(); personal.setJsonObject(response); AlUApplication.getUserfans().setId(personal.getId()); AlUApplication.getUserfans().setJifen(personal.getJifen()); AlUApplication.getUserfans().setUserName(personal.getUserName()); AlUApplication.getUserfans().setSocietyName(personal.getSocietyName()); // ????? AlUApplication.getInstance().setUserName(username); AlUApplication.getInstance().setPassword(password); User user = new User(); user.setId((long) userInfo.getID()); user.setUsername(username); user.setPassword(password); user.setChatuser(userInfo.getHXName()); saveUserToDB(user); /* runOnUiThread(new Runnable() { public void run() { pd.setMessage("..."); } }); */ EMChatManager.getInstance().login(userInfo.getHXName(), userInfo.getHXPwd(), new EMCallBack() { @Override public void onSuccess() { EMChatManager.getInstance().loadAllConversations(); } @Override public void onProgress(int progress, String status) { // TODO Auto-generated method stub } @Override public void onError(int code, String message) { // TODO Auto-generated method stub } }); // ** ?logout?? // ** manually load all local groups and // conversations in case we are auto login //EMGroupManager.getInstance().loadAllGroups(); // 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) { e.printStackTrace(); } //?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(LoginActivity.this, MainActivity.class)); finish(); } @Override public void onFailure(int statusCode, Header[] headers, final String responseString, Throwable throwable) { if (!progressShow) { return; } pd.dismiss(); runOnUiThread(new Runnable() { public void run() { //pd.dismiss(); //Toast.makeText(getApplicationContext(), ": " + responseString, 0).show(); } }); } }); } }