Search in sources :

Example 1 with HttpCallback

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();
            }
        });
    }
}
Also used : Context(android.content.Context) KeyEvent(android.view.KeyEvent) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick) PhoneApi(cn.cqautotest.sunnybeach.http.request.PhoneApi) CountdownView(com.hjq.widget.view.CountdownView) R(cn.cqautotest.sunnybeach.R) Intent(android.content.Intent) EasyHttp(com.hjq.http.EasyHttp) HttpCallback(com.hjq.http.listener.HttpCallback) DebugLog(cn.cqautotest.sunnybeach.aop.DebugLog) AnimationUtils(android.view.animation.AnimationUtils) IntentKey(cn.cqautotest.sunnybeach.other.IntentKey) TextView(android.widget.TextView) AppActivity(cn.cqautotest.sunnybeach.app.AppActivity) GetCodeApi(cn.cqautotest.sunnybeach.http.request.GetCodeApi) HintDialog(cn.cqautotest.sunnybeach.ui.dialog.HintDialog) View(android.view.View) Button(android.widget.Button) InputTextManager(cn.cqautotest.sunnybeach.manager.InputTextManager) HttpData(cn.cqautotest.sunnybeach.http.model.HttpData) Activity(android.app.Activity) EditorInfo(android.view.inputmethod.EditorInfo) EditText(android.widget.EditText) PhoneApi(cn.cqautotest.sunnybeach.http.request.PhoneApi) HintDialog(cn.cqautotest.sunnybeach.ui.dialog.HintDialog) GetCodeApi(cn.cqautotest.sunnybeach.http.request.GetCodeApi) HttpData(cn.cqautotest.sunnybeach.http.model.HttpData) HttpCallback(com.hjq.http.listener.HttpCallback) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick)

Aggregations

Activity (android.app.Activity)1 Context (android.content.Context)1 Intent (android.content.Intent)1 KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 AnimationUtils (android.view.animation.AnimationUtils)1 EditorInfo (android.view.inputmethod.EditorInfo)1 Button (android.widget.Button)1 EditText (android.widget.EditText)1 TextView (android.widget.TextView)1 R (cn.cqautotest.sunnybeach.R)1 DebugLog (cn.cqautotest.sunnybeach.aop.DebugLog)1 SingleClick (cn.cqautotest.sunnybeach.aop.SingleClick)1 AppActivity (cn.cqautotest.sunnybeach.app.AppActivity)1 HttpData (cn.cqautotest.sunnybeach.http.model.HttpData)1 GetCodeApi (cn.cqautotest.sunnybeach.http.request.GetCodeApi)1 PhoneApi (cn.cqautotest.sunnybeach.http.request.PhoneApi)1 InputTextManager (cn.cqautotest.sunnybeach.manager.InputTextManager)1 IntentKey (cn.cqautotest.sunnybeach.other.IntentKey)1 HintDialog (cn.cqautotest.sunnybeach.ui.dialog.HintDialog)1