private void authRegister() { if (mPhoneET.getText().toString().length() == 0) { new ToastView(this, "请输入手机号").show(); return; } if (mCodeET.getText().toString().length() == 0) { new ToastView(this, "请输入验证码").show(); return; } if (user != null) { APIControl.getInstance() .authRegister( this, user.getOpenId(), mPhoneET.getText().toString(), mCodeET.getText().toString(), user.getAccessToken(), type, user.getImgUrl(), user.getNickname(), user.getSex(), new DataResponseListener<UserData>() { @Override public void onResponse(UserData user) { // sendBroadcast(new Intent("com.geek.geekmall.action.auth")); if (user.getStatus() != 200) { new ToastView(BindAccountActivity.this, user.getErrorMsg()).show(); } else { GeekApplication.setUser(user.getData().getUserInfo()); SharedPreUtil.getInstance().putUser(user.getData().getUserInfo()); GeekApplication.setAgentInfo(user.getData().getAgentInfo()); GeekApplication.setOrderInfo(user.getData().getOrderInfo()); GeekApplication.setUserMoney(user.getData().getUserMoney()); // sendBroadcast(new // Intent("com.geek.geekmall.action.auth.sina")); // Intent intent = new // Intent(BindAccountActivity.this, MainActivity.class); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // startActivity(intent); sendBroadcast(new Intent("com.geek.geekmall.action.user_login")); finish(); } } }, errorListener("")); } }
private void initView() { mBackView = (TextView) findViewById(R.id.back); mBackView.setOnClickListener(this); mTitleView = (TextView) findViewById(R.id.title); mCodeBtn = (Button) findViewById(R.id.code_btn); mCodeBtn.setOnClickListener(this); mNextBtn = (Button) findViewById(R.id.next); mNextBtn.setOnClickListener(this); mNameView = (TextView) findViewById(R.id.name); mAvatorView = (ImageView) findViewById(R.id.avator); mPhoneET = (EditText) findViewById(R.id.phone); mCodeET = (EditText) findViewById(R.id.code); mPhoneET.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} @Override public void afterTextChanged(Editable s) { Pattern pattern = Pattern.compile(Constant.MOBILE_REG); if (pattern.matcher(mPhoneET.getText().toString()).matches()) { mCodeBtn.setEnabled(true); } else { mCodeBtn.setEnabled(false); } } }); if (user != null) { mNameView.setText(user.getNickname()); ImageLoader.getInstance(this) .getPicasso() .load(user.getImgUrl()) .transform(ImageLoader.getInstance(this).new RoundedCornersTransformation(120)) .placeholder(R.drawable.avatar_default) .into(mAvatorView); } }