use of cn.nicolite.palm300heroes.db.dao.EquipmentDao in project Palm300Heroes by nicolite.
the class EquJJCPresenter method showEquJJCList.
public void showEquJJCList(boolean isForce) {
final EquipmentDao equipmentDao = getDaoSession().getEquipmentDao();
if (!isForce && equipmentDao.count() > 0) {
if (getView() != null) {
List<Equipment> equipmentList = equipmentDao.queryBuilder().where(EquipmentDao.Properties.Type.eq("JJC")).orderAsc(EquipmentDao.Properties.Id).list();
getView().showEquJJCList(equipmentList);
}
return;
}
if (getView() != null) {
getView().showLoading();
}
BmobQuery<Equipment> query = new BmobQuery<>(Constants.BMOB_EQUIPMENT);
query.addWhereEqualTo("type", "JJC").order("id").setLimit(300).findObjects(new FindListener<Equipment>() {
@Override
public void done(final List<Equipment> list, BmobException e) {
if (getView() != null) {
getView().closeLoading();
if (e == null) {
getView().showEquJJCList(list);
if (!saveFlag) {
saveFlag = true;
new Thread(new Runnable() {
@Override
public void run() {
List<Equipment> jjcList = equipmentDao.queryBuilder().where(EquipmentDao.Properties.Type.eq("JJC")).list();
for (Equipment equipment : jjcList) {
equipmentDao.delete(equipment);
}
for (Equipment equipment : list) {
equipmentDao.insert(equipment);
}
saveFlag = false;
}
}).start();
}
} else {
getView().loadFailure();
BmobUtils.showErrorMessage(e.toString());
}
}
}
});
}
Aggregations