Search in sources :

Example 1 with SmartUser

use of com.itculturalfestival.smartcampus.entity.db.SmartUser in project SmartCampus by Vegen.

the class SignUpPresenter method signUpServer.

@Override
public void signUpServer(String phone, String password, String sex, String schoolName, Integer schoolId) {
    // SmartUser smartUser = new SmartUser();
    // smartUser.setPhone(phone);
    // smartUser.setPassword(password);
    // smartUser.setSex(sex);
    // smartUser.setSchoolName(schoolName);
    // smartUser.setSchoolId(schoolId);
    // smartUser.save(new SaveListener<String>() {
    // @Override
    // public void done(String s, BmobException e) {
    // if (e == null) {
    // if (mView != null) mView.hideLoading(false);
    // } else {
    // if (mView != null) {
    // mView.showMessage(e.getMessage());
    // mView.hideLoading(true);
    // }
    // }
    // }
    // });
    BmobUser bmobUser = new BmobUser();
    bmobUser.setUsername(phone);
    bmobUser.setPassword(password);
    bmobUser.signUp(new SaveListener<SmartUser>() {

        @Override
        public void done(SmartUser s, BmobException e) {
            if (e == null) {
                SmartUser newUser = new SmartUser();
                newUser.setSex(sex);
                newUser.setSchoolId(schoolId);
                newUser.setSchoolName(schoolName);
                SmartUser bmobUser = BmobUser.getCurrentUser(SmartUser.class);
                if (bmobUser != null) {
                    newUser.update(bmobUser.getObjectId(), new UpdateListener() {

                        @Override
                        public void done(BmobException e) {
                            if (e == null) {
                                if (mView != null)
                                    mView.hideLoading(false);
                            } else {
                                if (mView != null) {
                                    mView.showMessage(e.getMessage());
                                    mView.hideLoading(true);
                                }
                            }
                        }
                    });
                } else {
                    if (mView != null) {
                        mView.showMessage(e.getMessage());
                        mView.hideLoading(true);
                    }
                }
            } else {
                if (mView != null) {
                    mView.showMessage(e.getMessage());
                    mView.hideLoading(true);
                }
            }
        }
    });
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) SmartUser(com.itculturalfestival.smartcampus.entity.db.SmartUser) BmobUser(cn.bmob.v3.BmobUser) UpdateListener(cn.bmob.v3.listener.UpdateListener)

Example 2 with SmartUser

use of com.itculturalfestival.smartcampus.entity.db.SmartUser in project SmartCampus by Vegen.

the class LoginPresenter method getUserDetail.

/**
 * 从后端拿用户资料
 */
private void getUserDetail(String phone, String password) {
    SmartUser smartUser = new SmartUser();
    smartUser.setPhone(phone);
    smartUser.setPassword(password);
// smartUser.login(new SaveListener<SmartUser>() {
// @Override
// public void done(SmartUser smartUser1, BmobException e) {
// if (mView != null) {
// if (e == null) {
// // 请求成功
// if (smartUser1 == null){
// mView.showMessage("该用户不存在");
// }else {
// mView.loginSuccess(smartUser1);
// }
// mView.hideLoading(false);
// } else {
// mView.showMessage(HttpError.getErrorMessage(e));
// mView.hideLoading(true);
// }
// }
// }
// });
// BmobQuery<SmartUser> query = new BmobQuery<SmartUser>();
// query.addWhereEqualTo("phone", phone);
// query.addWhereEqualTo("password", password);
// Subscription subscription = query.findObjects(new FindListener<SmartUser>() {
// @Override
// public void done(List<SmartUser> list, BmobException e) {
// if (mView != null) {
// if (e == null) {
// // 请求成功
// if (list == null || list.isEmpty()){
// mView.showMessage("该用户不存在");
// }else {
// mView.loginSuccess(list.get(0));
// }
// mView.hideLoading(false);
// } else {
// mView.showMessage(HttpError.getErrorMessage(e));
// mView.hideLoading(true);
// }
// }
// }
// });
// mHttpLinkers.add(new SubscriptionHolder(subscription));
}
Also used : SmartUser(com.itculturalfestival.smartcampus.entity.db.SmartUser)

Aggregations

SmartUser (com.itculturalfestival.smartcampus.entity.db.SmartUser)2 BmobUser (cn.bmob.v3.BmobUser)1 BmobException (cn.bmob.v3.exception.BmobException)1 UpdateListener (cn.bmob.v3.listener.UpdateListener)1