use of cn.bmob.v3.listener.FindListener 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());
}
}
}
});
}
use of cn.bmob.v3.listener.FindListener in project expression by happy-yuxuan.
the class KDGerenZhuceActivity method dealResult.
// 加入成功后处理当前页面
private void dealResult() {
List<BmobQuery<MyUser>> queries = new ArrayList<BmobQuery<MyUser>>();
BmobQuery<MyUser> q1 = new BmobQuery<MyUser>();
q1.addQueryKeys("teamFlag");
BmobUser user = MyUser.getCurrentUser();
String username = user.getUsername();
BmobQuery<MyUser> q2 = new BmobQuery<MyUser>();
q2.addWhereEqualTo("username", username);
queries.add(q1);
queries.add(q2);
BmobQuery<MyUser> query = new BmobQuery<MyUser>();
query.and(queries);
query.findObjects(new FindListener<MyUser>() {
@Override
public void done(List<MyUser> object, BmobException e) {
if (e == null) {
MyUser u = object.get(0);
if (!u.getTeamFlag().equals("")) {
setET(u.getMobilePhoneNumber(), u.getEmail(), u.getRealName(), u.getIdCard());
}
} else {
L.i("error dealResult" + e.getMessage() + e.getErrorCode());
}
}
});
}
use of cn.bmob.v3.listener.FindListener in project expression by happy-yuxuan.
the class UMyInfomationActivity method setDataTOView.
// 设置数据到界面上
private void setDataTOView() {
// 获取缓存用户
BmobUser userQuery = MyUser.getCurrentUser();
// 获取缓存用户的用户名
String cacheUsername = userQuery.getUsername();
// 开始查询用户资料
BmobQuery<MyUser> query = new BmobQuery<MyUser>();
query.addWhereEqualTo("username", cacheUsername);
query.findObjects(new FindListener<MyUser>() {
@Override
public void done(List<MyUser> object, BmobException e) {
if (e == null) {
MyUser user = object.get(0);
String nichen = user.getUsername();
String phoneNumber = user.getMobilePhoneNumber();
String email = user.getEmail();
String idCard = user.getIdCard();
String realName = user.getRealName();
// 查询成功后将数据设置到EditText上
et_nichen.setText(nichen);
et_mail.setText(email);
et_idCard.setText(idCard);
et_phoneNumber.setText(phoneNumber);
et_real_name.setText(realName);
} else {
Toast.makeText(UMyInfomationActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
use of cn.bmob.v3.listener.FindListener in project expression by happy-yuxuan.
the class UMyOrdersActivity method queryData.
// 查数据
private void queryData() {
dialog.show();
List<BmobQuery<UserDqInfomation>> queries = new ArrayList<BmobQuery<UserDqInfomation>>();
BmobQuery<UserDqInfomation> q1 = new BmobQuery<UserDqInfomation>();
q1.addWhereEqualTo("success", false);
BmobUser user = MyUser.getCurrentUser();
String username = user.getUsername();
BmobQuery<UserDqInfomation> q2 = new BmobQuery<UserDqInfomation>();
q2.addWhereEqualTo("username", username);
queries.add(q1);
queries.add(q2);
BmobQuery<UserDqInfomation> query = new BmobQuery<UserDqInfomation>();
query.and(queries);
query.findObjects(new FindListener<UserDqInfomation>() {
@Override
public void done(List<UserDqInfomation> object, BmobException e) {
if (e == null) {
if (object.size() == 0) {
handler.sendEmptyMessage(CACHE_DATA_FAIL);
return;
}
data.clear();
L.i("queryData = " + object.size());
MyOrdersData buffer;
for (UserDqInfomation u : object) {
buffer = new MyOrdersData();
buffer.setAddr(u.getAddr());
buffer.setPhoneNumber(u.getDq_phone());
queryUsername(u.getDq_phone(), buffer);
}
} else {
L.i("queryData失败:" + e.getMessage());
handler.sendEmptyMessage(CACHE_DATA_FAIL);
Toast.makeText(UMyOrdersActivity.this, "加载失败", Toast.LENGTH_SHORT).show();
}
}
});
}
Aggregations