private void changePassword( final String oldPassword, final String newPassword, final String repeatNewPassword) { if (TextUtils.isEmpty(newPassword)) { showErrorToolTip( mNewPasswordErrorTooltip, getString(R.string.acct_message_new_password_mandatory)); return; } if (TextUtils.isEmpty(repeatNewPassword)) { showErrorToolTip( mRepeatNewPasswordErrorTooltip, getString(R.string.acct_message_repeat_new_password_mandatory)); return; } if (isValidPassword(oldPassword, newPassword, repeatNewPassword)) { // remove all error tooltips hideAllErrorTooltips(); // hide keyboard InputUtils.hideKeyboard(ChangePasswordActivity.this); // show progress dialog mProgressDialog.show(); AccountModel.getInstance() .changePassword( getApplicationContext(), oldPassword, newPassword, new ModelCallback<Void>() { @Override public void success(Void response) { mProgressDialog.dismiss(); Preferences.setPreference( getApplicationContext(), Preferences.PASSWORD, newPassword); Toast.makeText( getApplicationContext(), getString(R.string.acct_message_change_password_success), Toast.LENGTH_SHORT) .show(); finish(); } @Override public void error(Throwable throwable) { mProgressDialog.dismiss(); Toast.makeText( getApplicationContext(), getString(R.string.acct_message_change_password_failed), Toast.LENGTH_SHORT) .show(); } }); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: InputUtils.hideKeyboard(ChangePasswordActivity.this); finish(); return true; default: return super.onOptionsItemSelected(item); } }