Search in sources :

Example 1 with MyOrdersData

use of com.yuxuan.admin.expression.entity.MyOrdersData 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();
            }
        }
    });
}
Also used : MyUser(com.yuxuan.admin.expression.entity.MyUser) BmobException(cn.bmob.v3.exception.BmobException) UserDqInfomation(com.yuxuan.admin.expression.entity.UserDqInfomation) MyOrdersData(com.yuxuan.admin.expression.entity.MyOrdersData) FindListener(cn.bmob.v3.listener.FindListener) BmobQuery(cn.bmob.v3.BmobQuery) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with MyOrdersData

use of com.yuxuan.admin.expression.entity.MyOrdersData 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();
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) UserDqInfomation(com.yuxuan.admin.expression.entity.UserDqInfomation) BmobQuery(cn.bmob.v3.BmobQuery) BmobUser(cn.bmob.v3.BmobUser) ArrayList(java.util.ArrayList) MyOrdersData(com.yuxuan.admin.expression.entity.MyOrdersData)

Aggregations

BmobQuery (cn.bmob.v3.BmobQuery)2 BmobException (cn.bmob.v3.exception.BmobException)2 MyOrdersData (com.yuxuan.admin.expression.entity.MyOrdersData)2 UserDqInfomation (com.yuxuan.admin.expression.entity.UserDqInfomation)2 ArrayList (java.util.ArrayList)2 BmobUser (cn.bmob.v3.BmobUser)1 FindListener (cn.bmob.v3.listener.FindListener)1 MyUser (com.yuxuan.admin.expression.entity.MyUser)1 List (java.util.List)1