use of cn.bmob.v3.exception.BmobException in project Palm300Heroes by nicolite.
the class HeroDataPresenter method showHeroData.
public void showHeroData(final String UNCode, boolean isForce) {
final HeroBaseDataDao heroBaseDataDao = getDaoSession().getHeroBaseDataDao();
if (!isForce && getView() != null) {
List<HeroBaseData> list = heroBaseDataDao.queryBuilder().where(HeroBaseDataDao.Properties.UNCode.eq(UNCode)).list();
if (!ListUtils.isEmpty(list)) {
getView().showHeroData(list.get(0));
return;
}
}
BmobQuery<HeroBaseData> query = new BmobQuery<>(Constants.BMOB_HERO_DETAIL);
query.addWhereEqualTo("UNCode", UNCode).findObjects(new FindListener<HeroBaseData>() {
@Override
public void done(final List<HeroBaseData> list, BmobException e) {
if (getView() != null) {
if (e == null) {
if (!ListUtils.isEmpty(list)) {
getView().showHeroData(list.get(0));
if (!isSaving) {
isSaving = true;
new Thread(new Runnable() {
@Override
public void run() {
List<HeroBaseData> oldList = heroBaseDataDao.queryBuilder().where(HeroBaseDataDao.Properties.UNCode.eq(UNCode)).list();
for (HeroBaseData heroBaseData : oldList) {
heroBaseDataDao.delete(heroBaseData);
}
for (HeroBaseData heroBaseData : list) {
heroBaseDataDao.insert(heroBaseData);
}
isSaving = false;
}
}).start();
}
} else {
getView().showMessage("暂时没有相关数据");
getView().loadFailure();
}
} else {
getView().loadFailure();
BmobUtils.showErrorMessage(e.toString());
}
}
}
});
}
use of cn.bmob.v3.exception.BmobException in project Palm300Heroes by nicolite.
the class HeroSkinPresenter method showSkin.
public void showSkin(final String UNCode, boolean isForce) {
final SkinDao skinDao = getDaoSession().getSkinDao();
if (!isForce && getView() != null) {
List<Skin> list = skinDao.queryBuilder().where(SkinDao.Properties.UNCode.eq(UNCode)).list();
if (!ListUtils.isEmpty(list)) {
getView().showSkin(list);
return;
}
}
BmobQuery<Skin> query = new BmobQuery<>(Constants.BMOB_SKin);
query.addWhereEqualTo("UNCode", UNCode).findObjects(new FindListener<Skin>() {
@Override
public void done(final List<Skin> list, BmobException e) {
if (getView() != null) {
if (e == null) {
getView().showSkin(list);
if (!isSaving) {
isSaving = true;
new Thread(new Runnable() {
@Override
public void run() {
List<Skin> oldList = skinDao.queryBuilder().where(SkinDao.Properties.UNCode.eq(UNCode)).list();
for (Skin skin : oldList) {
skinDao.delete(skin);
}
for (Skin skin : list) {
skinDao.insert(skin);
}
isSaving = false;
}
}).start();
}
} else {
getView().loadFailure();
BmobUtils.showErrorMessage(e.toString());
}
}
}
});
}
use of cn.bmob.v3.exception.BmobException in project expression by happy-yuxuan.
the class UIdentifyPhoneActivity method bindMobilePhone.
// 绑定手机
private void bindMobilePhone(String phone) {
// 开发者在给用户绑定手机号码的时候需要提交两个字段的值:mobilePhoneNumber、mobilePhoneNumberVerified
MyUser user = new MyUser();
user.setMobilePhoneNumber(phone);
user.setMobilePhoneNumberVerified(true);
MyUser cur = BmobUser.getCurrentUser(MyUser.class);
user.update(cur.getObjectId(), new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
L.i("手机号码绑定成功");
Toast.makeText(UIdentifyPhoneActivity.this, "手机号码验证成功", Toast.LENGTH_LONG).show();
finish();
} else {
L.i("手机号码失败:" + e.getMessage());
Toast.makeText(UIdentifyPhoneActivity.this, "sorry 失败了", Toast.LENGTH_LONG).show();
}
}
});
}
use of cn.bmob.v3.exception.BmobException in project expression by happy-yuxuan.
the class UIdentifyPhoneActivity method submitVerify.
// 提交验证
private void submitVerify(final String mobileNumber, String identify_code) {
L.i("开始验证手机");
BmobSMS.verifySmsCode(mobileNumber, identify_code, new UpdateListener() {
@Override
public void done(BmobException ex) {
if (ex == null) {
// 短信验证码已验证成功
L.i("smile 验证通过 开始绑定");
// 验证手机成功,绑定用户
bindMobilePhone(mobileNumber);
} else {
L.i("smile 验证失败:code =" + ex.getErrorCode() + ",msg = " + ex.getLocalizedMessage());
}
}
});
}
use of cn.bmob.v3.exception.BmobException in project expression by happy-yuxuan.
the class UMyInfomationActivity method updataUser.
/**
* 修改User表,主要修改username, real_name, phone, email, idCard 字段
*/
private void updataUser() {
String username = et_nichen.getText().toString().trim();
String real_name = et_real_name.getText().toString().trim();
String phoneNumber = et_phoneNumber.getText().toString().trim();
String idCard = et_idCard.getText().toString().trim();
String email = et_mail.getText().toString().trim();
// 获取缓存用户的信息
final String cacheUsername = BmobUser.getCurrentUser().getUsername();
BmobUser cachebUser = BmobUser.getCurrentUser();
MyUser newUser = new MyUser();
if (!email.equals(cachebUser.getEmail())) {
newUser.setEmail(email);
}
if (!username.equals(cachebUser.getUsername())) {
newUser.setUsername(username);
}
if (!phoneNumber.equals(cachebUser.getMobilePhoneNumber())) {
newUser.setMobilePhoneNumber(phoneNumber);
}
newUser.setRealName(real_name);
newUser.setIdCard(idCard);
newUser.update(cachebUser.getObjectId(), new UpdateListener() {
@Override
public void done(BmobException e) {
dialog.dismiss();
if (e == null) {
Toast.makeText(UMyInfomationActivity.this, "修改资料成功", Toast.LENGTH_SHORT).show();
// 更新UserDqInfomation表(cacheUsername 是修改关键字)
updataUserDqInfomation(cacheUsername);
// 设置 EditText 为 未激活状态
setEditTextEnable(false);
} else {
Toast.makeText(UMyInfomationActivity.this, "修改失败:" + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
Aggregations