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();
}
});
}
}
});
}
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());
}
}
}
});
}
Aggregations