Search in sources :

Example 26 with BmobException

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

the class KDDQInfomationActivity method addInfo.

// 将数据保存到数据库(Bmob)   ?????
private void addInfo() {
    String phoneNumber = et_phoneNumber.getText().toString().trim();
    String name = et_name.getText().toString().trim();
    String addr = et_addr.getText().toString().trim();
    String status = et_status.getText().toString().trim();
    String other = et_other.getText().toString().trim();
    // 获取代取用户的手机号,即送件人
    String dq_phone = getIntent().getStringExtra("dq_phone");
    BmobUser user = MyUser.getCurrentUser();
    String username = user.getUsername();
    UserDqInfomation DqInfo = new UserDqInfomation();
    DqInfo.setUsername(username);
    DqInfo.setPhone(phoneNumber);
    DqInfo.setName(name);
    DqInfo.setAddr(addr);
    DqInfo.setStatus(status);
    DqInfo.setOther(other);
    DqInfo.setSuccess(false);
    if (!TextUtils.isEmpty(dq_phone)) {
        DqInfo.setDq_phone(dq_phone);
    }
    DqInfo.save(new SaveListener<String>() {

        @Override
        public void done(String objectId, BmobException e) {
            if (e == null) {
                // Toast.makeText(KDDQInfomationActivity.this, "创建数据成功:" + objectId, Toast.LENGTH_SHORT).show();
                L.i("添加ok");
                dialog.dismiss();
                new AlertDialog.Builder(KDDQInfomationActivity.this).setTitle("注意").setMessage("代取信息填写成功\n请到  '我的订单' 中查看详细信息\n我们稍后联系您,请保持信息畅通").setPositiveButton("我的订单?", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        startActivity(new Intent(KDDQInfomationActivity.this, UMyOrdersActivity.class));
                        finish();
                    }
                }).setNegativeButton("取消", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).show();
            } else {
                L.i("代取信息添加失败:" + e.getMessage());
                Toast.makeText(KDDQInfomationActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) UserDqInfomation(com.yuxuan.admin.expression.entity.UserDqInfomation) BmobUser(cn.bmob.v3.BmobUser) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent)

Example 27 with BmobException

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

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

the class MyInfoFragment method uploadImageHead.

// 上传图片到bmob
private void uploadImageHead(String bmString) {
    BitmapDrawable bitmap = (BitmapDrawable) getResources().getDrawable(R.drawable.add_pic);
    String addPicImgString = UtilTools.bitmapToString(getActivity(), bitmap);
    if (!bmString.equals(addPicImgString)) {
        MyUser newUser = new MyUser();
        newUser.setImgHead(bmString);
        BmobUser bmobUser = MyUser.getCurrentUser();
        newUser.update(bmobUser.getObjectId(), new UpdateListener() {

            @Override
            public void done(BmobException e) {
                if (e == null) {
                    L.i("上传头像成功");
                } else {
                    L.i("上传头像失败" + e);
                }
            }
        });
    }
}
Also used : MyUser(com.yuxuan.admin.expression.entity.MyUser) BmobException(cn.bmob.v3.exception.BmobException) BmobUser(cn.bmob.v3.BmobUser) BitmapDrawable(android.graphics.drawable.BitmapDrawable) UpdateListener(cn.bmob.v3.listener.UpdateListener)

Example 29 with BmobException

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

the class RegiestActivity method registFromBmob.

/**
 * 注册到 bmob云端
 *
 * @param username
 * @param password
 */
private void registFromBmob(final String username, final String password) {
    MyUser myUser = new MyUser();
    myUser.setUsername(username);
    myUser.setPassword(password);
    // 注意:不能用save方法进行注册
    myUser.signUp(new SaveListener<MyUser>() {

        @Override
        public void done(MyUser s, BmobException e) {
            dialog.dismiss();
            if (e == null) {
                Toast.makeText(RegiestActivity.this, "注册成功", Toast.LENGTH_SHORT).show();
                Intent intent = new Intent();
                intent.putExtra("username", username);
                intent.putExtra("password", password);
                setResult(RESULT_OK, intent);
                finish();
            } else {
                Toast.makeText(RegiestActivity.this, "注册失败", Toast.LENGTH_SHORT).show();
            }
        }
    });
}
Also used : MyUser(com.yuxuan.admin.expression.entity.MyUser) BmobException(cn.bmob.v3.exception.BmobException) Intent(android.content.Intent)

Example 30 with BmobException

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

the class KDTeamRegister method regiestTeam.

private void regiestTeam() {
    String team_phone = et_team_teleohone.getText().toString().trim();
    String team_mail = et_team_mail.getText().toString().trim();
    String tname = et_tname.getText().toString().trim();
    if (!TextUtils.isEmpty(team_phone) && !TextUtils.isEmpty(team_mail) && !TextUtils.isEmpty(tname)) {
        if (UtilTools.checkMobileNumber(team_phone) && UtilTools.checkEmail(team_mail)) {
            MyUser u = new MyUser();
            u.setMobilePhoneNumber(team_phone);
            u.setEmail(team_mail);
            u.setTeamFlag(tname);
            BmobUser bmobUser = MyUser.getCurrentUser();
            u.update(bmobUser.getObjectId(), new UpdateListener() {

                @Override
                public void done(BmobException e) {
                    if (e == null) {
                        Toast.makeText(KDTeamRegister.this, "注册成功", Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(KDTeamRegister.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                        L.i(e.getMessage() + e.getErrorCode());
                    }
                }
            });
        } else {
            if (!UtilTools.checkMobileNumber(team_phone)) {
                Toast.makeText(KDTeamRegister.this, "电话格式不正确", Toast.LENGTH_SHORT).show();
            } else if (!UtilTools.checkEmail(team_mail)) {
                Toast.makeText(KDTeamRegister.this, "邮箱格式不正确", Toast.LENGTH_SHORT).show();
            }
        }
    } else {
        Toast.makeText(KDTeamRegister.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)

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