use of cn.nicolite.palm300heroes.db.dao.FightSkillDao in project Palm300Heroes by nicolite.
the class FightSkillPresenter method showFightSkill.
public void showFightSkill(boolean isForce) {
final FightSkillDao fightSkillDao = getDaoSession().getFightSkillDao();
if (!isForce && fightSkillDao.count() > 0) {
if (getView() != null) {
List<FightSkill> list = fightSkillDao.queryBuilder().orderAsc(FightSkillDao.Properties.Position).list();
getView().showFightSkill(list);
}
return;
}
if (getView() != null) {
getView().showLoading();
}
BmobQuery<FightSkill> query = new BmobQuery<>(Constants.BMOB_FIGHT_SKILL);
query.setLimit(20).order("position").findObjects(new FindListener<FightSkill>() {
@Override
public void done(final List<FightSkill> list, BmobException e) {
if (getView() != null) {
getView().closeLoading();
if (e == null) {
getView().showFightSkill(list);
if (!saveFlag) {
saveFlag = true;
new Thread(new Runnable() {
@Override
public void run() {
fightSkillDao.deleteAll();
for (FightSkill fightSkill : list) {
fightSkillDao.insert(fightSkill);
}
saveFlag = false;
}
}).start();
}
} else {
BmobUtils.showErrorMessage(e.toString());
}
}
}
});
}
Aggregations