private void getRegisterCode() { /*Action=SendCheckMessage&mobile=18622816323&message=欢迎您注册设计猫*/ Map<String, String> params = new HashMap<>(); params.put("Action", "SendCheckMessage"); params.put("mobile", mobileEt.getText().toString()); params.put("message", "请输入此校验码完成注册;感谢您使用设计猫! 更多惊喜等着您!"); LoginRetrofit.getInstance() .getAuthCode(params) .compose(RegisterActivity.this.<LoginCodeEntity>bindUntilEvent(ActivityEvent.DESTROY)) .subscribe( new Action1<LoginCodeEntity>() { @Override public void call(LoginCodeEntity loginCodeEntity) { RegisterActivity.this.security = loginCodeEntity.getCode(); } }); }
@Nullable @OnClick(R.id.register_layout_register_btn) void onRegisterClick() { if (!RegisterActivity.this.security.equals(code)) { toast = DialogManager.getInstance() .showNoMoreDialog(RegisterActivity.this, Gravity.TOP, "验证码错误,请重新输入,O__O …"); return; } /* Username=linuxlan22221&Password=lanlan1111&Action=RegisterUser&Mobile_phone=18622816322&Email=adsfasdf%40aaa.com*/ Map<String, String> params = new HashMap<>(4); params.put("Action", "RegisterUser"); params.put("Username", userName); params.put("Mobile_phone", mobile); params.put("Password", password); subscription = LoginRetrofit.getInstance() .requestRegister(params) .doOnSubscribe( new Action0() { @Override public void call() { /*加载数据,显示进度条*/ if (progressDialog == null) { progressDialog = DialogManager.getInstance() .showSimpleProgressDialog(RegisterActivity.this, cancelListener); } else { progressDialog.show(); } } }) .doOnTerminate( new Action0() { @Override public void call() { /*隐藏进度条*/ if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } } }) .filter( new Func1<RegisterEntity, Boolean>() { @Override public Boolean call(RegisterEntity registerEntity) { return !subscription.isUnsubscribed(); } }) .compose(RegisterActivity.this.<RegisterEntity>bindUntilEvent(ActivityEvent.DESTROY)) .subscribe( new Action1<RegisterEntity>() { @Override public void call(RegisterEntity registerEntity) { Toast.makeText( RegisterActivity.this, registerEntity.getRegisterMessage(), Toast.LENGTH_LONG) .show(); if (registerEntity.getRegisterCode() == Constants.RESULT_OK) { RegisterActivity.this.exit(); } } }, new Action1<Throwable>() { @Override public void call(Throwable error) { toast = DialogManager.getInstance() .showNoMoreDialog( RegisterActivity.this, Gravity.TOP, "注册失败,请重试,O__O …"); } }); }