仿拉手团购App6--注册界面_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > 仿拉手团购App6--注册界面

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

 2017/5/17 5:32:13  ganchuanpu  程序员俱乐部  我要评论(0)
  • 摘要:获得验证码caseR.id.register_btn_getCode:mPhoneNumber=mEtPhoneNumber.getText().toString();if(LoginHelperUtil.isPhoneNumber(mPhoneNumber)){BmobManager.getInstance(newBmobMsgSendCallback(){@OverridepublicvoidonMsgSendSuccess(){ToastUtil.show
  • 标签:团购 APP

获得验证码

class="brush:java;gutter:true;">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;

  

 

发表评论
用户名: 匿名