use of cn.bmob.v3.listener.UpdateListener in project CoCoin by Nightonke.
the class SetPasswordActivity method buttonClickOperation.
private void buttonClickOperation(boolean longClick, int position) {
switch(CURRENT_STATE) {
case NEW_PASSWORD:
if (CoCoinUtil.ClickButtonDelete(position)) {
if (longClick) {
CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].init();
newPassword = "";
} else {
CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].clear(newPassword.length() - 1);
if (newPassword.length() != 0)
newPassword = newPassword.substring(0, newPassword.length() - 1);
}
} else if (CoCoinUtil.ClickButtonCommit(position)) {
} else {
CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].set(newPassword.length());
newPassword += CoCoinUtil.BUTTONS[position];
if (newPassword.length() == 4) {
// finish the new password input
CURRENT_STATE = PASSWORD_AGAIN;
viewPager.setCurrentItem(PASSWORD_AGAIN, true);
}
}
break;
case PASSWORD_AGAIN:
if (CoCoinUtil.ClickButtonDelete(position)) {
if (longClick) {
CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].init();
againPassword = "";
} else {
CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].clear(againPassword.length() - 1);
if (againPassword.length() != 0)
againPassword = againPassword.substring(0, againPassword.length() - 1);
}
} else if (CoCoinUtil.ClickButtonCommit(position)) {
} else {
CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].set(againPassword.length());
againPassword += CoCoinUtil.BUTTONS[position];
if (againPassword.length() == 4) {
// if the password again is equal to the new password
if (againPassword.equals(newPassword)) {
CURRENT_STATE = -1;
showToast(2);
SettingManager.getInstance().setPassword(newPassword);
SettingManager.getInstance().setFirstTime(false);
if (SettingManager.getInstance().getLoggenOn()) {
User currentUser = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
currentUser.setAccountBookPassword(newPassword);
currentUser.update(CoCoinApplication.getAppContext(), currentUser.getObjectId(), new UpdateListener() {
@Override
public void onSuccess() {
Log.d("Saver", "Set password successfully.");
}
@Override
public void onFailure(int code, String msg) {
Log.d("Saver", "Set password failed.");
}
});
}
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
}, 1000);
} else {
CoCoinFragmentManager.passwordChangeFragment[CURRENT_STATE].clear(4);
((PasswordChangeFragment) passwordAdapter.getItem(CURRENT_STATE - 1)).init();
CURRENT_STATE = NEW_PASSWORD;
viewPager.setCurrentItem(NEW_PASSWORD, true);
newPassword = "";
againPassword = "";
showToast(1);
}
}
}
break;
default:
break;
}
}
use of cn.bmob.v3.listener.UpdateListener in project expression by happy-yuxuan.
the class MyInfoFragment method uploadImageHead.
// 上传图片到bmob
private void uploadImageHead(String bmString) {
BitmapDrawable bitmap = (BitmapDrawable) getResources().getDrawable(R.drawable.add_pic);
String addPicImgString = UtilTools.bitmapToString(getActivity(), bitmap);
if (!bmString.equals(addPicImgString)) {
MyUser newUser = new MyUser();
newUser.setImgHead(bmString);
BmobUser bmobUser = MyUser.getCurrentUser();
newUser.update(bmobUser.getObjectId(), new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
L.i("上传头像成功");
} else {
L.i("上传头像失败" + e);
}
}
});
}
}
use of cn.bmob.v3.listener.UpdateListener in project expression by happy-yuxuan.
the class KDTeamRegister method regiestTeam.
private void regiestTeam() {
String team_phone = et_team_teleohone.getText().toString().trim();
String team_mail = et_team_mail.getText().toString().trim();
String tname = et_tname.getText().toString().trim();
if (!TextUtils.isEmpty(team_phone) && !TextUtils.isEmpty(team_mail) && !TextUtils.isEmpty(tname)) {
if (UtilTools.checkMobileNumber(team_phone) && UtilTools.checkEmail(team_mail)) {
MyUser u = new MyUser();
u.setMobilePhoneNumber(team_phone);
u.setEmail(team_mail);
u.setTeamFlag(tname);
BmobUser bmobUser = MyUser.getCurrentUser();
u.update(bmobUser.getObjectId(), new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
Toast.makeText(KDTeamRegister.this, "注册成功", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(KDTeamRegister.this, e.getMessage(), Toast.LENGTH_SHORT).show();
L.i(e.getMessage() + e.getErrorCode());
}
}
});
} else {
if (!UtilTools.checkMobileNumber(team_phone)) {
Toast.makeText(KDTeamRegister.this, "电话格式不正确", Toast.LENGTH_SHORT).show();
} else if (!UtilTools.checkEmail(team_mail)) {
Toast.makeText(KDTeamRegister.this, "邮箱格式不正确", Toast.LENGTH_SHORT).show();
}
}
} else {
Toast.makeText(KDTeamRegister.this, "信息不能为空", Toast.LENGTH_SHORT).show();
}
}
Aggregations