Search in sources :

Example 21 with FindListener

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());
                }
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) BmobQuery(cn.bmob.v3.BmobQuery) Hero(cn.nicolite.palm300heroes.model.bean.Hero) HeroDao(cn.nicolite.palm300heroes.db.dao.HeroDao)

Example 22 with FindListener

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

Example 23 with FindListener

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();
            }
        }
    });
}
Also used : MyUser(com.yuxuan.admin.expression.entity.MyUser) BmobException(cn.bmob.v3.exception.BmobException) BmobUser(cn.bmob.v3.BmobUser) BmobQuery(cn.bmob.v3.BmobQuery)

Example 24 with FindListener

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();
            }
        }
    });
}
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)23 BmobException (cn.bmob.v3.exception.BmobException)16 BmobUser (cn.bmob.v3.BmobUser)12 User (com.nightonke.saver.model.User)8 File (java.io.File)8 Logo (com.nightonke.saver.model.Logo)7 Bitmap (android.graphics.Bitmap)6 FutureCallback (com.koushikdutta.async.future.FutureCallback)6 FileInputStream (java.io.FileInputStream)6 FileNotFoundException (java.io.FileNotFoundException)6 List (java.util.List)6 BmobFile (cn.bmob.v3.datatype.BmobFile)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 UpdateListener (cn.bmob.v3.listener.UpdateListener)3 UserDqInfomation (com.yuxuan.admin.expression.entity.UserDqInfomation)3 SaveListener (cn.bmob.v3.listener.SaveListener)2 TalentDao (cn.nicolite.palm300heroes.db.dao.TalentDao)2 Talent (cn.nicolite.palm300heroes.model.bean.Talent)2 BmobProFile (com.bmob.BmobProFile)2