use of cn.bmob.v3.exception.BmobException in project Palm300Heroes by nicolite.
the class HeroSkillPresenter method showSkill.
public void showSkill(final String UNCode, boolean isForce) {
final SkillDao skillDao = getDaoSession().getSkillDao();
if (!isForce && getView() != null) {
List<Skill> list = skillDao.queryBuilder().where(SkillDao.Properties.UNCode.eq(UNCode)).list();
if (!ListUtils.isEmpty(list)) {
getView().showSkill(list);
return;
}
}
BmobQuery<Skill> query = new BmobQuery<>(Constants.BMOB_SKILL);
query.addWhereEqualTo("UNCode", UNCode).findObjects(new FindListener<Skill>() {
@Override
public void done(final List<Skill> list, BmobException e) {
if (getView() != null) {
if (e == null) {
if (!ListUtils.isEmpty(list)) {
getView().showSkill(list);
if (!isSaving) {
isSaving = true;
new Thread(new Runnable() {
@Override
public void run() {
List<Skill> oldList = skillDao.queryBuilder().where(SkillDao.Properties.UNCode.eq(UNCode)).list();
for (Skill skill : oldList) {
skillDao.delete(skill);
}
for (Skill skill : list) {
skillDao.save(skill);
}
isSaving = false;
}
}).start();
}
}
} else {
getView().loadFailure();
BmobUtils.showErrorMessage(e.toString());
}
}
}
});
}
use of cn.bmob.v3.exception.BmobException in project Palm300Heroes by nicolite.
the class HeroSoundPresenter method showSound.
public void showSound(final String UNCode, boolean isForce) {
final SoundDao soundDao = getDaoSession().getSoundDao();
if (!isForce && getView() != null) {
List<Sound> list = soundDao.queryBuilder().where(SoundDao.Properties.UNCode.eq(UNCode)).list();
if (!ListUtils.isEmpty(list)) {
getView().showSound(list);
return;
}
}
BmobQuery<Sound> query = new BmobQuery<>(Constants.BMOB_Sound);
query.addWhereEqualTo("UNCode", UNCode).findObjects(new FindListener<Sound>() {
@Override
public void done(final List<Sound> list, BmobException e) {
if (getView() != null) {
if (e == null) {
getView().showSound(list);
if (!isSaving) {
isSaving = true;
new Thread(new Runnable() {
@Override
public void run() {
List<Sound> oldList = soundDao.queryBuilder().where(SoundDao.Properties.UNCode.eq(UNCode)).list();
for (Sound sound : oldList) {
soundDao.delete(sound);
}
for (Sound sound : list) {
soundDao.insert(sound);
}
isSaving = false;
}
}).start();
}
} else {
getView().loadFailure();
BmobUtils.showErrorMessage(e.toString());
}
}
}
});
}
use of cn.bmob.v3.exception.BmobException in project Palm300Heroes by nicolite.
the class HeroListPresenter method showHeroList.
public void showHeroList(boolean isForce) {
final HeroDao heroDao = getDaoSession().getHeroDao();
if (!isForce && heroDao.count() > 0) {
if (getView() != null) {
List<Hero> heroList = heroDao.queryBuilder().orderDesc(HeroDao.Properties.Position).list();
getView().showHeroList(heroList);
}
return;
}
if (getView() != null) {
getView().showLoading();
}
BmobQuery<Hero> query = new BmobQuery<>(Constants.BMOB_HERO);
query.setLimit(300).order("-position").findObjects(new FindListener<Hero>() {
@Override
public void done(final List<Hero> list, BmobException e) {
if (getView() != null) {
getView().closeLoading();
if (e == null) {
getView().showHeroList(list);
if (!saveFlag) {
saveFlag = true;
new Thread(new Runnable() {
@Override
public void run() {
heroDao.deleteAll();
for (Hero hero : list) {
heroDao.insert(hero);
}
saveFlag = false;
}
}).start();
}
} else {
getView().loadFailure();
BmobUtils.showErrorMessage(e.toString());
}
}
}
});
}
use of cn.bmob.v3.exception.BmobException in project LivingInCampus by DulCoder.
the class LoginFragment method login.
private void login() {
name = et_login.getText().toString();
password = et_password.getText().toString();
final MyUser user = new MyUser();
user.setUsername(name);
user.setPassword(password);
user.login(new SaveListener<MyUser>() {
@Override
public void done(MyUser myUser, BmobException e) {
try {
if (e == null) {
MyApplication.editor.putBoolean("isChecked", cb_choice.isChecked());
if (cb_choice.isChecked()) {
editor.putString("name", name);
editor.putString("password", password);
}
String icon = myUser.getMyIcon();
String nickName = myUser.getNickName();
editor.putString("icon", icon);
editor.putString("nickName", nickName);
editor.commit();
getActivity().finish();
} else {
Log.e("err1", e.getErrorCode() + "" + e.getMessage());
}
} catch (Exception exception) {
Log.e("err", exception.getMessage() + "");
Utils.toast(mContext, "正在登录");
}
}
});
}
use of cn.bmob.v3.exception.BmobException in project LivingInCampus by DulCoder.
the class RegisterFragment method register.
/**
* 注册相关逻辑
*/
private void register(String login, String password, String nickName, String myIcon) {
MyUser user = new MyUser();
email = et_email.getText().toString();
user.setEmail(email);
user.setNickName(nickName);
user.setMyIcon(myIcon);
user.setUsername(login);
user.setPassword(password);
try {
user.signUp(new SaveListener<MyUser>() {
@Override
public void done(MyUser myUser, BmobException e) {
if (e == null) {
toast("注册成功");
goBack();
} else {
int error = e.getErrorCode();
toast("e" + error);
}
}
});
} catch (Exception exception) {
Log.e("ERROR", exception.getMessage());
}
}
Aggregations