Esempio n. 1
0
  private void register() {
    if (mTelphoneEditText.getText().toString() == "") {
      MyToast.show(RegisterActivity.this, "手机号输入不正确", 1000);
      return;
    }
    if (mCodeEditText.getText().toString() == "") {
      MyToast.show(RegisterActivity.this, "请输入手机验证码", 1000);
      return;
    }
    if (mPasswordEditText.getText().toString().length() > 20
        || mPasswordEditText.getText().toString().length() < 6) {
      MyToast.show(RegisterActivity.this, "请输入6-20位密码", 1000);
      return;
    }
    if (!mPasswordEditText.getText().toString().equals(mRePasswordEditText.getText().toString())) {
      MyToast.show(RegisterActivity.this, "两次输入密码不一致", 1000);
      return;
    }

    if (!((CheckBox) findViewById(R.id.register_checkbox)).isChecked()) {
      MyToast.show(RegisterActivity.this, "请同意I踢球用户协议", 1000);
      return;
    }

    final RegisterInfo info = new RegisterInfo();
    info.setCellPhone(mTelphoneEditText.getText().toString());
    info.setConfirmKey(mCodeEditText.getText().toString());
    info.setPassword(mPasswordEditText.getText().toString());
    info.setRePassword(mRePasswordEditText.getText().toString());
    info.setFromLinkSource(2);
    info.setGender(2);

    new MyAsyncTask<ResultData<CustomerInfo>>(this) {

      @Override
      public ResultData<CustomerInfo> callService()
          throws IOException, JsonParseException, BizException, ServiceException {
        return new CustomerService().register(info);
      }

      @Override
      public void onLoaded(ResultData<CustomerInfo> result) throws Exception {
        if (!result.isSuccess()) {
          MyToast.show(RegisterActivity.this, result.getMessage(), 1000);
        } else {
          mTelphoneEditText.setText("");
          mCodeEditText.setText("");
          mPasswordEditText.setText("");
          mRePasswordEditText.setText("");
          MyToast.show(RegisterActivity.this, "注册成功", 1000);
        }
      }
    }.executeTask();
  }
Esempio n. 2
0
  private void sendCode(final Button v) {
    if (!StringUtil.isPhone(mTelphoneEditText.getText().toString())) {
      MyToast.show(RegisterActivity.this, "手机号输入不正确", 1000);
    } else {
      v.setClickable(false);
      new MyAsyncTask<ResultData<String>>(this) {

        @Override
        public ResultData<String> callService()
            throws IOException, JsonParseException, BizException, ServiceException {
          return new CustomerService().sendValidateCode(mTelphoneEditText.getText().toString());
        }

        @Override
        public void onLoaded(ResultData<String> result) throws Exception {
          if (!result.isSuccess()) {
            MyToast.show(RegisterActivity.this, result.getMessage(), 1000);
          } else {
            final Timer timer = new Timer();
            timer.schedule(
                new TimerTask() {

                  @Override
                  public void run() {
                    runOnUiThread(
                        new Runnable() {
                          @Override
                          public void run() {
                            int s = Integer.parseInt(v.getTag().toString()) - 1;
                            v.setTag(s);
                            v.setText(String.format("%s秒后重新发送", s));
                            if (s == 0) {
                              v.setText("获取验证码");
                              v.setClickable(true);
                              v.setTag("60");
                              timer.cancel();
                            }
                          }
                        });
                  }
                },
                1000,
                1000);
          }
        }
      }.executeTask();
    }
  }