Search in sources :

Example 11 with BmobException

use of cn.bmob.v3.exception.BmobException 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();
            }
        }
    });
}
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) UpdateListener(cn.bmob.v3.listener.UpdateListener)

Example 12 with BmobException

use of cn.bmob.v3.exception.BmobException 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 13 with BmobException

use of cn.bmob.v3.exception.BmobException in project expression by happy-yuxuan.

the class KDGerenZhuceActivity method regiestPerson.

private void regiestPerson() {
    String phoneNumber = et_phoneNumber.getText().toString().trim();
    String email = et_mail.getText().toString().trim();
    String realName = et_real_name.getText().toString().trim();
    String idCard = et_idcard.getText().toString().trim();
    if (UtilTools.checkMobileNumber(phoneNumber) && !TextUtils.isEmpty(realName) && !TextUtils.isEmpty(idCard) && UtilTools.checkEmail(email)) {
        // 更新
        MyUser newUser = new MyUser();
        newUser.setEmail(email);
        newUser.setMobilePhoneNumber(phoneNumber);
        newUser.setRealName(realName);
        newUser.setIdCard(idCard);
        newUser.setTeamFlag("1");
        BmobUser bmobUser = MyUser.getCurrentUser();
        newUser.update(bmobUser.getObjectId(), new UpdateListener() {

            @Override
            public void done(BmobException e) {
                if (e == null) {
                    Toast.makeText(KDGerenZhuceActivity.this, "加入成功", Toast.LENGTH_SHORT).show();
                    dealResult();
                } else {
                    Toast.makeText(KDGerenZhuceActivity.this, "加入失败" + e, Toast.LENGTH_SHORT).show();
                    L.d(e.getErrorCode() + "");
                }
            }
        });
    } else {
        if (!UtilTools.checkMobileNumber(phoneNumber)) {
            Toast.makeText(this, "电话输入格式不正确", Toast.LENGTH_SHORT).show();
        } else if (!UtilTools.checkEmail(email)) {
            Toast.makeText(this, "邮箱格式不正确", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(this, "信息填写不完整", Toast.LENGTH_SHORT).show();
        }
    }
}
Also used : MyUser(com.yuxuan.admin.expression.entity.MyUser) BmobException(cn.bmob.v3.exception.BmobException) BmobUser(cn.bmob.v3.BmobUser) UpdateListener(cn.bmob.v3.listener.UpdateListener)

Example 14 with BmobException

use of cn.bmob.v3.exception.BmobException in project expression by happy-yuxuan.

the class LoginActivity method loginInBmob.

/**
 * 登录到Bmob 云平台
 *
 * @param username
 * @param password
 */
private void loginInBmob(final String username, final String password) {
    dialog.show();
    MyUser myUser = new MyUser();
    myUser.setUsername(username);
    myUser.setPassword(password);
    myUser.login(new SaveListener<BmobUser>() {

        @Override
        public void done(BmobUser bmobUser, BmobException e) {
            dialog.dismiss();
            if (e == null) {
                Intent intent = new Intent();
                intent.setAction("com.index.IndexActivity");
                intent.putExtra("username", username);
                remberPWD(username, password);
                startActivity(intent);
                finish();
            } else {
                Toast.makeText(LoginActivity.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) Intent(android.content.Intent)

Example 15 with BmobException

use of cn.bmob.v3.exception.BmobException in project LivingInCampus by DulCoder.

the class AddCommunityFragment method publish.

/**
 * 发布信息的相关逻辑
 */
private void publish() {
    icon = Config.getMyIcon();
    nickname = Config.getNickName();
    if (icon != null && nickname != null) {
        // 判断是否登录
        content = etCommunity.getText().toString();
        if (TextUtils.isEmpty(content)) {
            Utils.toast(mContext, "输入不能为空");
        } else if (content.length() > 140) {
            Utils.toast(mContext, "内容字数不能大于140");
        } else {
            Date date = new Date();
            DateFormat format = DateFormat.getDateTimeInstance();
            // 获取当前时间
            datetime = format.format(date);
            MyUser user = BmobUser.getCurrentUser(MyUser.class);
            final CommunityItem communityItem = new CommunityItem();
            communityItem.setMyIcon(icon);
            communityItem.setNickName(nickname);
            communityItem.setDatetime(datetime);
            communityItem.setContent(content);
            communityItem.setAuthor(user);
            communityItem.save(new SaveListener<String>() {

                @Override
                public void done(String s, BmobException e) {
                    if (e != null) {
                        Utils.toast(mContext, e.getErrorCode() + e.getMessage());
                    } else {
                        getFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.community_container, CommunityFragment.newInstance()).commit();
                    }
                }
            });
        }
    } else {
        Utils.toast(mContext, "请登录");
    }
}
Also used : SaveListener(cn.bmob.v3.listener.SaveListener) MyUser(com.fafu.zhengxianyou.livingincampus.bean.MyUser) BmobException(cn.bmob.v3.exception.BmobException) DateFormat(java.text.DateFormat) CommunityItem(com.fafu.zhengxianyou.livingincampus.bean.CommunityItem) Date(java.util.Date)

Aggregations

BmobException (cn.bmob.v3.exception.BmobException)32 BmobQuery (cn.bmob.v3.BmobQuery)16 BmobUser (cn.bmob.v3.BmobUser)12 MyUser (com.yuxuan.admin.expression.entity.MyUser)10 UpdateListener (cn.bmob.v3.listener.UpdateListener)9 List (java.util.List)6 Intent (android.content.Intent)5 UserDqInfomation (com.yuxuan.admin.expression.entity.UserDqInfomation)4 ArrayList (java.util.ArrayList)4 MyUser (com.fafu.zhengxianyou.livingincampus.bean.MyUser)3 DialogInterface (android.content.DialogInterface)2 TalentDao (cn.nicolite.palm300heroes.db.dao.TalentDao)2 Talent (cn.nicolite.palm300heroes.model.bean.Talent)2 SubscriptionHolder (com.itculturalfestival.smartcampus.network.SubscriptionHolder)2 MyOrdersData (com.yuxuan.admin.expression.entity.MyOrdersData)2 Subscription (rx.Subscription)2 Bitmap (android.graphics.Bitmap)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Uri (android.net.Uri)1 AlertDialog (android.support.v7.app.AlertDialog)1