Search in sources :

Example 6 with BmobException

use of cn.bmob.v3.exception.BmobException in project Palm300Heroes by nicolite.

the class HeroDataPresenter method showHeroData.

public void showHeroData(final String UNCode, boolean isForce) {
    final HeroBaseDataDao heroBaseDataDao = getDaoSession().getHeroBaseDataDao();
    if (!isForce && getView() != null) {
        List<HeroBaseData> list = heroBaseDataDao.queryBuilder().where(HeroBaseDataDao.Properties.UNCode.eq(UNCode)).list();
        if (!ListUtils.isEmpty(list)) {
            getView().showHeroData(list.get(0));
            return;
        }
    }
    BmobQuery<HeroBaseData> query = new BmobQuery<>(Constants.BMOB_HERO_DETAIL);
    query.addWhereEqualTo("UNCode", UNCode).findObjects(new FindListener<HeroBaseData>() {

        @Override
        public void done(final List<HeroBaseData> list, BmobException e) {
            if (getView() != null) {
                if (e == null) {
                    if (!ListUtils.isEmpty(list)) {
                        getView().showHeroData(list.get(0));
                        if (!isSaving) {
                            isSaving = true;
                            new Thread(new Runnable() {

                                @Override
                                public void run() {
                                    List<HeroBaseData> oldList = heroBaseDataDao.queryBuilder().where(HeroBaseDataDao.Properties.UNCode.eq(UNCode)).list();
                                    for (HeroBaseData heroBaseData : oldList) {
                                        heroBaseDataDao.delete(heroBaseData);
                                    }
                                    for (HeroBaseData heroBaseData : list) {
                                        heroBaseDataDao.insert(heroBaseData);
                                    }
                                    isSaving = false;
                                }
                            }).start();
                        }
                    } else {
                        getView().showMessage("暂时没有相关数据");
                        getView().loadFailure();
                    }
                } else {
                    getView().loadFailure();
                    BmobUtils.showErrorMessage(e.toString());
                }
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) BmobQuery(cn.bmob.v3.BmobQuery) List(java.util.List) HeroBaseData(cn.nicolite.palm300heroes.model.bean.HeroBaseData) HeroBaseDataDao(cn.nicolite.palm300heroes.db.dao.HeroBaseDataDao)

Example 7 with BmobException

use of cn.bmob.v3.exception.BmobException in project Palm300Heroes by nicolite.

the class HeroSkinPresenter method showSkin.

public void showSkin(final String UNCode, boolean isForce) {
    final SkinDao skinDao = getDaoSession().getSkinDao();
    if (!isForce && getView() != null) {
        List<Skin> list = skinDao.queryBuilder().where(SkinDao.Properties.UNCode.eq(UNCode)).list();
        if (!ListUtils.isEmpty(list)) {
            getView().showSkin(list);
            return;
        }
    }
    BmobQuery<Skin> query = new BmobQuery<>(Constants.BMOB_SKin);
    query.addWhereEqualTo("UNCode", UNCode).findObjects(new FindListener<Skin>() {

        @Override
        public void done(final List<Skin> list, BmobException e) {
            if (getView() != null) {
                if (e == null) {
                    getView().showSkin(list);
                    if (!isSaving) {
                        isSaving = true;
                        new Thread(new Runnable() {

                            @Override
                            public void run() {
                                List<Skin> oldList = skinDao.queryBuilder().where(SkinDao.Properties.UNCode.eq(UNCode)).list();
                                for (Skin skin : oldList) {
                                    skinDao.delete(skin);
                                }
                                for (Skin skin : list) {
                                    skinDao.insert(skin);
                                }
                                isSaving = false;
                            }
                        }).start();
                    }
                } else {
                    getView().loadFailure();
                    BmobUtils.showErrorMessage(e.toString());
                }
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) SkinDao(cn.nicolite.palm300heroes.db.dao.SkinDao) BmobQuery(cn.bmob.v3.BmobQuery) Skin(cn.nicolite.palm300heroes.model.bean.Skin) List(java.util.List)

Example 8 with BmobException

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

the class UIdentifyPhoneActivity method bindMobilePhone.

// 绑定手机
private void bindMobilePhone(String phone) {
    // 开发者在给用户绑定手机号码的时候需要提交两个字段的值:mobilePhoneNumber、mobilePhoneNumberVerified
    MyUser user = new MyUser();
    user.setMobilePhoneNumber(phone);
    user.setMobilePhoneNumberVerified(true);
    MyUser cur = BmobUser.getCurrentUser(MyUser.class);
    user.update(cur.getObjectId(), new UpdateListener() {

        @Override
        public void done(BmobException e) {
            if (e == null) {
                L.i("手机号码绑定成功");
                Toast.makeText(UIdentifyPhoneActivity.this, "手机号码验证成功", Toast.LENGTH_LONG).show();
                finish();
            } else {
                L.i("手机号码失败:" + e.getMessage());
                Toast.makeText(UIdentifyPhoneActivity.this, "sorry 失败了", Toast.LENGTH_LONG).show();
            }
        }
    });
}
Also used : MyUser(com.yuxuan.admin.expression.entity.MyUser) BmobException(cn.bmob.v3.exception.BmobException) UpdateListener(cn.bmob.v3.listener.UpdateListener)

Example 9 with BmobException

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

the class UIdentifyPhoneActivity method submitVerify.

// 提交验证
private void submitVerify(final String mobileNumber, String identify_code) {
    L.i("开始验证手机");
    BmobSMS.verifySmsCode(mobileNumber, identify_code, new UpdateListener() {

        @Override
        public void done(BmobException ex) {
            if (ex == null) {
                // 短信验证码已验证成功
                L.i("smile 验证通过 开始绑定");
                // 验证手机成功,绑定用户
                bindMobilePhone(mobileNumber);
            } else {
                L.i("smile 验证失败:code =" + ex.getErrorCode() + ",msg = " + ex.getLocalizedMessage());
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) UpdateListener(cn.bmob.v3.listener.UpdateListener)

Example 10 with BmobException

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

the class UMyInfomationActivity method updataUser.

/**
 * 修改User表,主要修改username, real_name, phone, email, idCard 字段
 */
private void updataUser() {
    String username = et_nichen.getText().toString().trim();
    String real_name = et_real_name.getText().toString().trim();
    String phoneNumber = et_phoneNumber.getText().toString().trim();
    String idCard = et_idCard.getText().toString().trim();
    String email = et_mail.getText().toString().trim();
    // 获取缓存用户的信息
    final String cacheUsername = BmobUser.getCurrentUser().getUsername();
    BmobUser cachebUser = BmobUser.getCurrentUser();
    MyUser newUser = new MyUser();
    if (!email.equals(cachebUser.getEmail())) {
        newUser.setEmail(email);
    }
    if (!username.equals(cachebUser.getUsername())) {
        newUser.setUsername(username);
    }
    if (!phoneNumber.equals(cachebUser.getMobilePhoneNumber())) {
        newUser.setMobilePhoneNumber(phoneNumber);
    }
    newUser.setRealName(real_name);
    newUser.setIdCard(idCard);
    newUser.update(cachebUser.getObjectId(), new UpdateListener() {

        @Override
        public void done(BmobException e) {
            dialog.dismiss();
            if (e == null) {
                Toast.makeText(UMyInfomationActivity.this, "修改资料成功", Toast.LENGTH_SHORT).show();
                // 更新UserDqInfomation表(cacheUsername 是修改关键字)
                updataUserDqInfomation(cacheUsername);
                // 设置 EditText 为 未激活状态
                setEditTextEnable(false);
            } 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) 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