Search in sources :

Example 1 with TalentDao

use of cn.nicolite.palm300heroes.db.dao.TalentDao in project Palm300Heroes by nicolite.

the class UpdateDataModel method updateTalent.

public static void updateTalent() {
    BmobQuery<Talent> query = new BmobQuery<>(Constants.BMOB_TALENT);
    query.setLimit(45).order("position").findObjects(new FindListener<Talent>() {

        @Override
        public void done(final List<Talent> list, BmobException e) {
            if (e == null) {
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        TalentDao talentDao = daoSession.getTalentDao();
                        talentDao.deleteAll();
                        for (Talent talent : list) {
                            talentDao.insert(talent);
                        }
                        progress.incrementAndGet();
                    }
                });
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) TalentDao(cn.nicolite.palm300heroes.db.dao.TalentDao) BmobQuery(cn.bmob.v3.BmobQuery) Talent(cn.nicolite.palm300heroes.model.bean.Talent)

Example 2 with TalentDao

use of cn.nicolite.palm300heroes.db.dao.TalentDao in project Palm300Heroes by nicolite.

the class TalentPresenter method showTalent.

public void showTalent(boolean isForce) {
    final TalentDao talentDao = getDaoSession().getTalentDao();
    if (!isForce && talentDao.count() > 0) {
        if (getView() != null) {
            List<Talent> list = talentDao.queryBuilder().orderAsc(TalentDao.Properties.Position).list();
            getView().showTalentList(list);
        }
        return;
    }
    if (getView() != null) {
        getView().showLoading();
    }
    BmobQuery<Talent> query = new BmobQuery<>(Constants.BMOB_TALENT);
    query.setLimit(45).order("position").findObjects(new FindListener<Talent>() {

        @Override
        public void done(final List<Talent> list, BmobException e) {
            if (getView() != null) {
                getView().closeLoading();
                if (e == null) {
                    getView().showTalentList(list);
                    if (!saveFlag) {
                        saveFlag = true;
                        new Thread(new Runnable() {

                            @Override
                            public void run() {
                                for (Talent talent : list) {
                                    talentDao.insert(talent);
                                }
                                saveFlag = false;
                            }
                        });
                    }
                } else {
                    BmobUtils.showErrorMessage(e.toString());
                }
            }
        }
    });
}
Also used : TalentDao(cn.nicolite.palm300heroes.db.dao.TalentDao) BmobException(cn.bmob.v3.exception.BmobException) BmobQuery(cn.bmob.v3.BmobQuery) Talent(cn.nicolite.palm300heroes.model.bean.Talent)

Aggregations

BmobQuery (cn.bmob.v3.BmobQuery)2 BmobException (cn.bmob.v3.exception.BmobException)2 TalentDao (cn.nicolite.palm300heroes.db.dao.TalentDao)2 Talent (cn.nicolite.palm300heroes.model.bean.Talent)2