鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 手机系统开发 > android > >

仿拉手团购App6--注册界面

来源:互联网 作者:佚名 时间:2018-03-04 16:12
获得验证码 case R.id.register_btn_getCode: mPhoneNumber = mEtPhoneNumber.getText().toString(); if (LoginHelperUtil.isPhoneNumber(mPhoneNumber)) { BmobManager.getInstance(new BmobMsgSendCallback() { @Override public void onMsgSendSuccess()

获得验证码

case R.id.register_btn_getCode:
    mPhoneNumber = mEtPhoneNumber.getText().toString();
    if (LoginHelperUtil.isPhoneNumber(mPhoneNumber)) {
        BmobManager.getInstance(new BmobMsgSendCallback() {
            @Override
            public void onMsgSendSuccess() {
                ToastUtil.show(RegisterActivity.this,R.string.sms_code_send_success);
                //验证码发送成功,倒计时
                setCodeTimeDown();
            }

            @Override
            public void onMsgSendFailure() {
                ToastUtil.show(RegisterActivity.this,R.string.sms_code_send_failure);
            }
        }).sendMsgCode(mPhoneNumber);
    } else {
        ToastUtil.show(this,R.string.phone_number_incorrect);
    }
    break;

  

private void setCodeTimeDown() {
    mBtnGetCode.setEnabled(false);
    final Timer timer = new Timer();
    mSecCount = 60;
    TimerTask timerTask = new TimerTask() {
        @Override
        public void run() {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mSecCount--;
                    mBtnGetCode.setText(mSecCount+" s");
                    if (mSecCount<=0) {
                        timer.cancel();
                        mBtnGetCode.setText(R.string.reSend);
                        mBtnGetCode.setEnabled(true);
                    }
                }
            });
        }
    };
    timer.schedule(timerTask,1000,1000);
}

  

注册

case R.id.register_btn_register:
    mPhoneNumber = mEtPhoneNumber.getText().toString();
    mMsgCode = mEtCode.getText().toString();
    mPassword = mEtPassword.getText().toString();
    mRepassword = mEtRepassword.getText().toString();
    if (LoginHelperUtil.isPhoneNumber(mPhoneNumber) && LoginHelperUtil.isCodeCorrect(mMsgCode)
            && TextUtils.equals(mPassword,mRepassword)) {
        BmobManager.getInstance(new BmobSignUpCallback() {
            @Override
            public void onSignUpSuccess(User user) {
                Intent intent = new Intent(RegisterActivity.this,MainActivity.class);
                intent.putExtra(INTENT_USER,user);
                startActivity(intent);
                ToastUtil.show(RegisterActivity.this,R.string.register_success);
                finish();
            }

            @Override
            public void onSignUpFailure(BmobException e) {
                ToastUtil.show(RegisterActivity.this,R.string.register_failure);
            }
        }).signUp(mPhoneNumber,mMsgCode,mPassword);
    } else {
        ToastUtil.show(this,R.string.register_input_incorrect);
    }
    break;

  

 

网友评论
<