use of cn.bmob.v3.listener.FindListener in project expression by happy-yuxuan.
the class UMyOrdersActivity method dealResult.
private void dealResult() {
L.i("da_phone = " + tv_phone.getText().toString());
L.i("addr = " + tv_addr.getText().toString());
List<BmobQuery<UserDqInfomation>> queries = new ArrayList<BmobQuery<UserDqInfomation>>();
BmobQuery<UserDqInfomation> q1 = new BmobQuery<UserDqInfomation>();
q1.addWhereEqualTo("dq_phone", tv_phone.getText().toString());
BmobQuery<UserDqInfomation> q2 = new BmobQuery<UserDqInfomation>();
q2.addWhereEqualTo("addr", tv_addr.getText().toString());
BmobQuery<UserDqInfomation> q3 = new BmobQuery<UserDqInfomation>();
BmobUser user = MyUser.getCurrentUser();
String username = user.getUsername();
q3.addWhereEqualTo("username", username);
queries.add(q1);
queries.add(q2);
queries.add(q3);
// 找到objId
BmobQuery<UserDqInfomation> query = new BmobQuery<UserDqInfomation>();
query.and(queries);
// 执行查询方法 获得 objId
query.findObjects(new FindListener<UserDqInfomation>() {
@Override
public void done(List<UserDqInfomation> object, BmobException e) {
if (e == null) {
UserDqInfomation udi = new UserDqInfomation();
udi.setSuccess(true);
// 执行更新方法
udi.update(object.get(0).getObjectId(), new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
L.i(" success 更新成功");
displayList.dismiss();
queryData();
Toast.makeText(UMyOrdersActivity.this, "代取成功,我们将一直为您服务", Toast.LENGTH_SHORT).show();
} else {
L.i("bmob 更新失败:" + e.getMessage() + "," + e.getErrorCode());
Toast.makeText(UMyOrdersActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
} else {
L.i("query dq_phone at UMyOrderActivity 失败:" + e.getMessage() + "," + e.getErrorCode());
Toast.makeText(UMyOrdersActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
use of cn.bmob.v3.listener.FindListener in project expression by happy-yuxuan.
the class UMyPaiJianActivity method initData.
// 从bmob获取数据
private void initData() {
dialog.show();
// 查询所有下单代取的用户
BmobQuery<UserDqInfomation> query = new BmobQuery<UserDqInfomation>();
query.addWhereEqualTo("success", false);
query.findObjects(new FindListener<UserDqInfomation>() {
@Override
public void done(List<UserDqInfomation> object, BmobException e) {
if (e == null) {
L.i("queryAllData = " + object.size());
for (final UserDqInfomation u : object) {
String dq_phone = u.getDq_phone();
// 查询当前用户需要派送的用户
BmobQuery<MyUser> q = new BmobQuery<MyUser>();
q.addWhereEqualTo("mobilePhoneNumber", dq_phone);
q.findObjects(new FindListener<MyUser>() {
@Override
public void done(List<MyUser> object, BmobException e) {
dialog.dismiss();
if (e == null) {
MyOrdersData buffer;
String sendUsername = object.get(0).getUsername();
String username = BmobUser.getCurrentUser().getUsername();
L.i(username + "--" + sendUsername);
if (sendUsername.equals(username)) {
String rusername = u.getUsername();
String addr = u.getAddr();
String phone = u.getPhone();
String status = u.getStatus();
String other = u.getOther();
buffer = new MyOrdersData();
buffer.setUsername(rusername);
buffer.setAddr(addr);
buffer.setPhoneNumber(phone);
buffer.setOther(other);
buffer.setStatus(status);
data.add(buffer);
hander.sendEmptyMessage(StaticClass.LOAD_DATA_OK);
}
} else {
L.i("querDqUsername fail:" + e.getMessage());
hander.sendEmptyMessage(StaticClass.LOAD_DATA_FAIL);
Toast.makeText(UMyPaiJianActivity.this, "加载数据失败", Toast.LENGTH_SHORT).show();
}
}
});
}
} else {
L.i("queryteamFlag fail:" + e.getMessage());
hander.sendEmptyMessage(StaticClass.LOAD_DATA_FAIL);
Toast.makeText(UMyPaiJianActivity.this, "加载数据失败", Toast.LENGTH_SHORT).show();
}
}
});
}
use of cn.bmob.v3.listener.FindListener in project SmartCampus by Vegen.
the class LostAndFoundPresenter method getLostList.
@Override
public void getLostList(int SKIP, int skip) {
BmobQuery<Lost> query = new BmobQuery<Lost>();
// query.setCachePolicy(BmobQuery.CachePolicy.CACHE_THEN_NETWORK); // 先从缓存获取数据,如果没有,再从网络获取。
// 按照时间降序
query.order("-createdAt");
// 每次加载条数
query.setLimit(SKIP);
// 偏移量
query.setSkip(skip);
Subscription subscription = query.findObjects(new FindListener<Lost>() {
@Override
public void done(List<Lost> list, BmobException e) {
if (mView != null) {
if (e == null) {
// 请求成功
mView.showLostList(list);
mView.hideLoading(false);
if (list == null || list.isEmpty()) {
mView.loadMoreEnd(true);
}
} else {
mView.showMessage(HttpError.getErrorMessage(e));
mView.hideLoading(true);
mView.loadMoreFail();
}
}
}
});
mHttpLinkers.add(new SubscriptionHolder(subscription));
}
use of cn.bmob.v3.listener.FindListener in project CoCoin by Nightonke.
the class AccountBookListViewActivity method loadLogo.
private void loadLogo() {
User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
if (user != null) {
try {
File logoFile = new File(CoCoinApplication.getAppContext().getFilesDir() + CoCoinUtil.LOGO_NAME);
if (!logoFile.exists()) {
// the local logo file is missed
// try to get from the server
BmobQuery<Logo> bmobQuery = new BmobQuery();
bmobQuery.addWhereEqualTo("objectId", user.getLogoObjectId());
bmobQuery.findObjects(CoCoinApplication.getAppContext(), new FindListener<Logo>() {
@Override
public void onSuccess(List<Logo> object) {
// there has been an old logo in the server/////////////////////////////////////////////////////////
String url = object.get(0).getFile().getFileUrl(CoCoinApplication.getAppContext());
if (BuildConfig.DEBUG)
Log.d("CoCoin", "Logo in server: " + url);
Ion.with(CoCoinApplication.getAppContext()).load(url).write(new File(CoCoinApplication.getAppContext().getFilesDir() + CoCoinUtil.LOGO_NAME)).setCallback(new FutureCallback<File>() {
@Override
public void onCompleted(Exception e, File file) {
profileImage.setImageBitmap(BitmapFactory.decodeFile(CoCoinApplication.getAppContext().getFilesDir() + CoCoinUtil.LOGO_NAME));
}
});
}
@Override
public void onError(int code, String msg) {
// the picture is lost
if (BuildConfig.DEBUG)
Log.d("CoCoin", "Can't find the old logo in server.");
}
});
} else {
// the user logo is in the storage
Bitmap b = BitmapFactory.decodeStream(new FileInputStream(logoFile));
profileImage.setImageBitmap(b);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
} else {
// use the default logo
profileImage.setImageResource(R.drawable.default_user_logo);
}
}
use of cn.bmob.v3.listener.FindListener in project CoCoin by Nightonke.
the class AccountBookMonthViewActivity method loadLogo.
private void loadLogo() {
User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
if (user != null) {
try {
File logoFile = new File(CoCoinApplication.getAppContext().getFilesDir() + CoCoinUtil.LOGO_NAME);
if (!logoFile.exists()) {
// the local logo file is missed
// try to get from the server
BmobQuery<Logo> bmobQuery = new BmobQuery();
bmobQuery.addWhereEqualTo("objectId", user.getLogoObjectId());
bmobQuery.findObjects(CoCoinApplication.getAppContext(), new FindListener<Logo>() {
@Override
public void onSuccess(List<Logo> object) {
// there has been an old logo in the server/////////////////////////////////////////////////////////
String url = object.get(0).getFile().getFileUrl(CoCoinApplication.getAppContext());
if (BuildConfig.DEBUG)
Log.d("CoCoin", "Logo in server: " + url);
Ion.with(CoCoinApplication.getAppContext()).load(url).write(new File(CoCoinApplication.getAppContext().getFilesDir() + CoCoinUtil.LOGO_NAME)).setCallback(new FutureCallback<File>() {
@Override
public void onCompleted(Exception e, File file) {
profileImage.setImageBitmap(BitmapFactory.decodeFile(CoCoinApplication.getAppContext().getFilesDir() + CoCoinUtil.LOGO_NAME));
}
});
}
@Override
public void onError(int code, String msg) {
// the picture is lost
if (BuildConfig.DEBUG)
Log.d("CoCoin", "Can't find the old logo in server.");
}
});
} else {
// the user logo is in the storage
Bitmap b = BitmapFactory.decodeStream(new FileInputStream(logoFile));
profileImage.setImageBitmap(b);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
} else {
// use the default logo
profileImage.setImageResource(R.drawable.default_user_logo);
}
}
Aggregations