Search in sources :

Example 21 with BmobException

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());
                }
            }
        }
    });
}
Also used : Skill(cn.nicolite.palm300heroes.model.bean.Skill) BmobException(cn.bmob.v3.exception.BmobException) BmobQuery(cn.bmob.v3.BmobQuery) List(java.util.List) SkillDao(cn.nicolite.palm300heroes.db.dao.SkillDao)

Example 22 with BmobException

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());
                }
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) BmobQuery(cn.bmob.v3.BmobQuery) Sound(cn.nicolite.palm300heroes.model.bean.Sound) List(java.util.List) SoundDao(cn.nicolite.palm300heroes.db.dao.SoundDao)

Example 23 with BmobException

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());
                }
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) BmobQuery(cn.bmob.v3.BmobQuery) Hero(cn.nicolite.palm300heroes.model.bean.Hero) HeroDao(cn.nicolite.palm300heroes.db.dao.HeroDao)

Example 24 with BmobException

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, "正在登录");
            }
        }
    });
}
Also used : MyUser(com.fafu.zhengxianyou.livingincampus.bean.MyUser) BmobException(cn.bmob.v3.exception.BmobException) BmobException(cn.bmob.v3.exception.BmobException)

Example 25 with BmobException

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());
    }
}
Also used : MyUser(com.fafu.zhengxianyou.livingincampus.bean.MyUser) BmobException(cn.bmob.v3.exception.BmobException) BmobException(cn.bmob.v3.exception.BmobException)

Aggregations

BmobException (cn.bmob.v3.exception.BmobException)32 BmobQuery (cn.bmob.v3.BmobQuery)16 BmobUser (cn.bmob.v3.BmobUser)12 MyUser (com.yuxuan.admin.expression.entity.MyUser)10 UpdateListener (cn.bmob.v3.listener.UpdateListener)9 List (java.util.List)6 Intent (android.content.Intent)5 UserDqInfomation (com.yuxuan.admin.expression.entity.UserDqInfomation)4 ArrayList (java.util.ArrayList)4 MyUser (com.fafu.zhengxianyou.livingincampus.bean.MyUser)3 DialogInterface (android.content.DialogInterface)2 TalentDao (cn.nicolite.palm300heroes.db.dao.TalentDao)2 Talent (cn.nicolite.palm300heroes.model.bean.Talent)2 SubscriptionHolder (com.itculturalfestival.smartcampus.network.SubscriptionHolder)2 MyOrdersData (com.yuxuan.admin.expression.entity.MyOrdersData)2 Subscription (rx.Subscription)2 Bitmap (android.graphics.Bitmap)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Uri (android.net.Uri)1 AlertDialog (android.support.v7.app.AlertDialog)1