use of com.hjq.http.listener.HttpCallback in project SunnyBeach by anjiemo.
the class PhoneResetActivity method onClick.
@SingleClick
@Override
public void onClick(View view) {
if (view == mCountdownView) {
if (mPhoneView.getText().toString().length() != 11) {
mPhoneView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim));
toast(R.string.common_phone_input_error);
return;
}
if (true) {
toast(R.string.common_code_send_hint);
mCountdownView.start();
return;
}
// 获取验证码
EasyHttp.post(this).api(new GetCodeApi().setPhone(mPhoneView.getText().toString())).request(new HttpCallback<HttpData<Void>>(this) {
@Override
public void onSucceed(HttpData<Void> data) {
toast(R.string.common_code_send_hint);
mCountdownView.start();
}
});
} else if (view == mCommitView) {
if (mPhoneView.getText().toString().length() != 11) {
mPhoneView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim));
toast(R.string.common_phone_input_error);
return;
}
if (mCodeView.getText().toString().length() != getResources().getInteger(R.integer.sms_code_length)) {
// ToastUtils.show(R.string.common_code_error_hint);
return;
}
// 隐藏软键盘
hideKeyboard(getCurrentFocus());
if (true) {
new HintDialog.Builder(this).setIcon(HintDialog.ICON_FINISH).setMessage(R.string.phone_reset_commit_succeed).setDuration(2000).addOnDismissListener(dialog -> finish()).show();
return;
}
// 更换手机号
EasyHttp.post(this).api(new PhoneApi().setPreCode(mVerifyCode).setPhone(mPhoneView.getText().toString()).setCode(mCodeView.getText().toString())).request(new HttpCallback<HttpData<Void>>(this) {
@Override
public void onSucceed(HttpData<Void> data) {
new HintDialog.Builder(getActivity()).setIcon(HintDialog.ICON_FINISH).setMessage(R.string.phone_reset_commit_succeed).setDuration(2000).addOnDismissListener(dialog -> finish()).show();
}
});
}
}
Aggregations