Search in sources :

Example 1 with SingleClick

use of cn.cqautotest.sunnybeach.aop.SingleClick in project SunnyBeach by anjiemo.

the class PasswordForgetActivity method onSingleClick.

@SingleClick
private void onSingleClick(View view) {
    if (view == mCountdownView) {
        if (TextUtils.isEmpty(mInputVerifyCodeView.getText())) {
            mInputVerifyCodeView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim));
            toast(R.string.common_verify_code_input_hint);
            return;
        }
        if (mPhoneView.getText().toString().length() != 11) {
            mPhoneView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim));
            toast(R.string.common_phone_input_error);
            return;
        }
        // 隐藏软键盘
        hideKeyboard(getCurrentFocus());
        SmsInfo smsInfo = new SmsInfo(mPhoneView.getText().toString(), mInputVerifyCodeView.getText().toString());
        // 发送验证码
        mUserViewModel.sendForgetSmsVerifyCode(smsInfo).observe(this, result -> {
            toast(result.getMessage());
            mCountdownView.start();
        });
    } else if (view == mCommitView) {
        if (TextUtils.isEmpty(mInputVerifyCodeView.getText())) {
            mInputVerifyCodeView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim));
            toast(R.string.common_verify_code_input_hint);
            return;
        }
        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)) {
            mCodeView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim));
            toast(R.string.common_code_error_hint);
            return;
        }
        String phoneNumber = mPhoneView.getText().toString();
        String smsCode = mCodeView.getText().toString();
        // 验证码校验
        mUserViewModel.checkSmsCode(phoneNumber, smsCode).observe(this, result -> {
            toast(result.getMessage());
            if (!result.isSuccess()) {
                PasswordResetActivity.start(getContext(), phoneNumber, smsCode);
                finish();
            }
        });
    }
}
Also used : KeyEvent(android.view.KeyEvent) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick) ViewModelProvider(androidx.lifecycle.ViewModelProvider) CountdownView(com.hjq.widget.view.CountdownView) ImageView(android.widget.ImageView) R(cn.cqautotest.sunnybeach.R) GlideApp(cn.cqautotest.sunnybeach.http.glide.GlideApp) Constants(cn.cqautotest.sunnybeach.util.Constants) TextUtils(android.text.TextUtils) UserViewModel(cn.cqautotest.sunnybeach.viewmodel.UserViewModel) AnimationUtils(android.view.animation.AnimationUtils) SmsInfo(cn.cqautotest.sunnybeach.model.SmsInfo) TextView(android.widget.TextView) AppActivity(cn.cqautotest.sunnybeach.app.AppActivity) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) View(android.view.View) Button(android.widget.Button) InputTextManager(cn.cqautotest.sunnybeach.manager.InputTextManager) EditorInfo(android.view.inputmethod.EditorInfo) EditText(android.widget.EditText) SmsInfo(cn.cqautotest.sunnybeach.model.SmsInfo) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick)

Example 2 with SingleClick

use of cn.cqautotest.sunnybeach.aop.SingleClick in project SunnyBeach by anjiemo.

the class PasswordResetActivity method onSingleClick.

@SingleClick
private void onSingleClick(View view) {
    if (view == mCommitView) {
        if (TextUtils.isEmpty(mOldPassword.getText())) {
            mOldPassword.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim));
            toast(R.string.password_reset_phone_old_password_hint);
            return;
        }
        if (!mFirstPassword.getText().toString().equals(mSecondPassword.getText().toString())) {
            mFirstPassword.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim));
            mSecondPassword.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim));
            toast(R.string.common_password_input_unlike);
            return;
        }
        // 隐藏软键盘
        hideKeyboard(getCurrentFocus());
        String oldPwd = mOldPassword.getText().toString();
        String newPwd = mFirstPassword.getText().toString();
        String captcha = mInputResetVerifyCode.getText().toString();
        ModifyPwd modifyPwd = new ModifyPwd(oldPwd, newPwd, captcha);
        // 修改密码
        mUserViewModel.modifyPassword(modifyPwd).observe(this, result -> {
            if (result.isSuccess()) {
                new HintDialog.Builder(getContext()).setIcon(HintDialog.ICON_FINISH).setMessage(R.string.password_reset_success).setDuration(2000).addOnDismissListener(dialog -> finish()).show();
            } else {
                toast(result.getMessage());
            }
        });
    }
}
Also used : Context(android.content.Context) KeyEvent(android.view.KeyEvent) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick) ImageView(android.widget.ImageView) GlideApp(cn.cqautotest.sunnybeach.http.glide.GlideApp) Constants(cn.cqautotest.sunnybeach.util.Constants) Intent(android.content.Intent) AnimationUtils(android.view.animation.AnimationUtils) IntentKey(cn.cqautotest.sunnybeach.other.IntentKey) AppActivity(cn.cqautotest.sunnybeach.app.AppActivity) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) HintDialog(cn.cqautotest.sunnybeach.ui.dialog.HintDialog) View(android.view.View) Button(android.widget.Button) ViewModelProvider(androidx.lifecycle.ViewModelProvider) R(cn.cqautotest.sunnybeach.R) TextUtils(android.text.TextUtils) UserViewModel(cn.cqautotest.sunnybeach.viewmodel.UserViewModel) DebugLog(cn.cqautotest.sunnybeach.aop.DebugLog) TextView(android.widget.TextView) ModifyPwd(cn.cqautotest.sunnybeach.model.ModifyPwd) InputTextManager(cn.cqautotest.sunnybeach.manager.InputTextManager) Activity(android.app.Activity) EditorInfo(android.view.inputmethod.EditorInfo) EditText(android.widget.EditText) HintDialog(cn.cqautotest.sunnybeach.ui.dialog.HintDialog) ModifyPwd(cn.cqautotest.sunnybeach.model.ModifyPwd) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick)

Example 3 with SingleClick

use of cn.cqautotest.sunnybeach.aop.SingleClick in project SunnyBeach by anjiemo.

the class PersonalDataActivity method onClick.

@SingleClick
@Override
public void onClick(View view) {
    if (view == mAvatarLayout) {
        ImageSelectActivity.start(this, data -> {
            // 裁剪头像
            cropImage(new File(data.get(0)));
        });
    } else if (view == mAvatarView) {
        if (!TextUtils.isEmpty(mAvatarUrl)) {
            // 查看头像
            ImagePreviewActivity.start(this, mAvatarUrl);
        } else {
            // 选择头像
            onClick(mAvatarLayout);
        }
    } else if (view == mNameView) {
        new InputDialog.Builder(this).setTitle(getString(R.string.personal_data_name_hint)).setContent(mNameView.getRightText()).setListener((dialog, content) -> {
            if (!mNameView.getRightText().equals(content)) {
                mNameView.setRightText(content);
            }
        }).show();
    } else if (view == mAddressView) {
        new AddressDialog.Builder(this).setProvince(mProvince).setCity(mCity).setListener((dialog, province, city, area) -> {
            String address = province + city + area;
            if (!mAddressView.getRightText().equals(address)) {
                mProvince = province;
                mCity = city;
                mArea = area;
                mAddressView.setRightText(address);
            }
        }).show();
    }
}
Also used : SettingBar(com.hjq.widget.layout.SettingBar) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick) MultiTransformation(com.bumptech.glide.load.MultiTransformation) Date(java.util.Date) Uri(android.net.Uri) ImageView(android.widget.ImageView) GlideApp(cn.cqautotest.sunnybeach.http.glide.GlideApp) SimpleDateFormat(java.text.SimpleDateFormat) Intent(android.content.Intent) CenterCrop(com.bumptech.glide.load.resource.bitmap.CenterCrop) CircleCrop(com.bumptech.glide.load.resource.bitmap.CircleCrop) AppActivity(cn.cqautotest.sunnybeach.app.AppActivity) AddressDialog(cn.cqautotest.sunnybeach.ui.dialog.AddressDialog) Locale(java.util.Locale) MediaStore(android.provider.MediaStore) View(android.view.View) Build(android.os.Build) UpdateImageApi(cn.cqautotest.sunnybeach.http.request.UpdateImageApi) AppConfig(cn.cqautotest.sunnybeach.other.AppConfig) R(cn.cqautotest.sunnybeach.R) TextUtils(android.text.TextUtils) EasyHttp(com.hjq.http.EasyHttp) InputDialog(cn.cqautotest.sunnybeach.ui.dialog.InputDialog) ViewGroup(android.view.ViewGroup) File(java.io.File) HttpCallback(com.hjq.http.listener.HttpCallback) Bitmap(android.graphics.Bitmap) FileProvider(androidx.core.content.FileProvider) HttpData(cn.cqautotest.sunnybeach.http.model.HttpData) AddressDialog(cn.cqautotest.sunnybeach.ui.dialog.AddressDialog) File(java.io.File) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick)

Example 4 with SingleClick

use of cn.cqautotest.sunnybeach.aop.SingleClick in project SunnyBeach by anjiemo.

the class DialogActivity method onClick.

@SingleClick
@Override
public void onClick(View view) {
    int viewId = view.getId();
    if (viewId == R.id.btn_dialog_message) {
        // 消息对话框
        new MessageDialog.Builder(getActivity()).setTitle("我是标题").setMessage("我是内容").setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).setListener(new MessageDialog.OnListener() {

            @Override
            public void onConfirm(BaseDialog dialog) {
                toast("确定了");
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_input) {
        // 输入对话框
        new InputDialog.Builder(this).setTitle("我是标题").setContent("我是内容").setHint("我是提示").setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).setListener(new InputDialog.OnListener() {

            @Override
            public void onConfirm(BaseDialog dialog, String content) {
                toast("确定了:" + content);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_bottom_menu) {
        List<String> data = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            data.add("我是数据" + (i + 1));
        }
        // 底部选择框
        new MenuDialog.Builder(this).setList(data).setListener(new MenuDialog.OnListener<String>() {

            @Override
            public void onSelected(BaseDialog dialog, int position, String string) {
                toast("位置:" + position + ",文本:" + string);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_center_menu) {
        List<String> data = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            data.add("我是数据" + (i + 1));
        }
        // 居中选择框
        new MenuDialog.Builder(this).setGravity(Gravity.CENTER).setList(data).setListener(new MenuDialog.OnListener<String>() {

            @Override
            public void onSelected(BaseDialog dialog, int position, String string) {
                toast("位置:" + position + ",文本:" + string);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_single_select) {
        // 单选对话框
        new SelectDialog.Builder(this).setTitle("请选择你的性别").setList("男", "女").setSingleSelect().setSelect(0).setListener(new SelectDialog.OnListener<String>() {

            @Override
            public void onSelected(BaseDialog dialog, HashMap<Integer, String> data) {
                toast("确定了:" + data.toString());
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_more_select) {
        // 多选对话框
        new SelectDialog.Builder(this).setTitle("请选择工作日").setList("星期一", "星期二", "星期三", "星期四", "星期五").setMaxSelect(3).setSelect(2, 3, 4).setListener(new SelectDialog.OnListener<String>() {

            @Override
            public void onSelected(BaseDialog dialog, HashMap<Integer, String> data) {
                toast("确定了:" + data.toString());
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_succeed_toast) {
        // 成功对话框
        new TipsDialog.Builder(this).setIcon(TipsDialog.ICON_FINISH).setMessage("完成").show();
    } else if (viewId == R.id.btn_dialog_fail_toast) {
        // 失败对话框
        new TipsDialog.Builder(this).setIcon(TipsDialog.ICON_ERROR).setMessage("错误").show();
    } else if (viewId == R.id.btn_dialog_warn_toast) {
        // 警告对话框
        new TipsDialog.Builder(this).setIcon(TipsDialog.ICON_WARNING).setMessage("警告").show();
    } else if (viewId == R.id.btn_dialog_wait) {
        if (mWaitDialog == null) {
            mWaitDialog = new WaitDialog.Builder(this).setMessage(getString(R.string.common_loading)).create();
        }
        if (!mWaitDialog.isShowing()) {
            mWaitDialog.show();
            postDelayed(mWaitDialog::dismiss, 2000);
        }
    } else if (viewId == R.id.btn_dialog_pay) {
        // 支付密码输入对话框
        new PayPasswordDialog.Builder(this).setTitle(getString(R.string.pay_title)).setSubTitle("用于购买一个女盆友").setMoney("¥ 100.00").setListener(new PayPasswordDialog.OnListener() {

            @Override
            public void onCompleted(BaseDialog dialog, String password) {
                toast(password);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_address) {
        // 选择地区对话框
        new AddressDialog.Builder(this).setTitle(getString(R.string.address_title)).setListener(new AddressDialog.OnListener() {

            @Override
            public void onSelected(BaseDialog dialog, String province, String city, String area) {
                toast(province + city + area);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_date) {
        // 日期选择对话框
        new DateDialog.Builder(this).setTitle(getString(R.string.date_title)).setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).setListener(new DateDialog.OnListener() {

            @Override
            public void onSelected(BaseDialog dialog, int year, int month, int day) {
                toast(year + getString(R.string.common_year) + month + getString(R.string.common_month) + day + getString(R.string.common_day));
                // 如果不指定时分秒则默认为现在的时间
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.YEAR, year);
                // 月份从零开始,所以需要减 1
                calendar.set(Calendar.MONTH, month - 1);
                calendar.set(Calendar.DAY_OF_MONTH, day);
                toast("时间戳:" + calendar.getTimeInMillis());
            // toast(new SimpleDateFormat("yyyy年MM月dd日 kk:mm:ss").format(calendar.getTime()));
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_time) {
        // 时间选择对话框
        new TimeDialog.Builder(this).setTitle(getString(R.string.time_title)).setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).setListener(new TimeDialog.OnListener() {

            @Override
            public void onSelected(BaseDialog dialog, int hour, int minute, int second) {
                toast(hour + getString(R.string.common_hour) + minute + getString(R.string.common_minute) + second + getString(R.string.common_second));
                // 如果不指定年月日则默认为今天的日期
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.HOUR_OF_DAY, hour);
                calendar.set(Calendar.MINUTE, minute);
                calendar.set(Calendar.SECOND, second);
                toast("时间戳:" + calendar.getTimeInMillis());
            // toast(new SimpleDateFormat("yyyy年MM月dd日 kk:mm:ss").format(calendar.getTime()));
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_share) {
        toast("记得改好第三方 AppID 和 Secret,否则会调不起来哦");
        UMWeb content = new UMWeb("https://github.com/getActivity/AndroidProject");
        content.setTitle("Github");
        content.setThumb(new UMImage(this, R.mipmap.launcher_ic));
        content.setDescription(getString(R.string.app_name));
        // 分享对话框
        new ShareDialog.Builder(this).setShareLink(content).setListener(new UmengShare.OnShareListener() {

            @Override
            public void onSucceed(Platform platform) {
                toast("分享成功");
            }

            @Override
            public void onError(Platform platform, Throwable t) {
                toast(t.getMessage());
            }

            @Override
            public void onCancel(Platform platform) {
                toast("分享取消");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_update) {
        // 升级对话框
        new UpdateDialog.Builder(this).setVersionName("5.2.0").setForceUpdate(false).setUpdateLog("到底更新了啥\n到底更新了啥\n到底更新了啥\n到底更新了啥\n到底更新了啥\n到底更新了啥").setDownloadUrl("https://dldir1.qq.com/weixin/android/weixin807android1920_arm64.apk").setFileMd5("df2f045dfa854d8461d9cefe08b813c8").show();
    } else if (viewId == R.id.btn_dialog_safe) {
        // 身份校验对话框
        new SafeDialog.Builder(this).setListener(new SafeDialog.OnListener() {

            @Override
            public void onConfirm(BaseDialog dialog, String phone, String code) {
                toast("手机号:" + phone + "\n验证码:" + code);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_custom) {
        // 自定义对话框
        new BaseDialog.Builder<>(this).setContentView(R.layout.custom_dialog).setAnimStyle(BaseDialog.ANIM_SCALE).setOnClickListener(R.id.btn_dialog_custom_ok, (BaseDialog.OnClickListener<Button>) (dialog, button) -> dialog.dismiss()).setOnCreateListener(dialog -> toast("Dialog 创建了")).addOnShowListener(dialog -> toast("Dialog 显示了")).addOnCancelListener(dialog -> toast("Dialog 取消了")).addOnDismissListener(dialog -> toast("Dialog 销毁了")).setOnKeyListener((dialog, event) -> {
            toast("按键代码:" + event.getKeyCode());
            return false;
        }).show();
    } else if (viewId == R.id.btn_dialog_multi) {
        BaseDialog dialog1 = new MessageDialog.Builder(getActivity()).setTitle("温馨提示").setMessage("我是第一个弹出的对话框").setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).create();
        BaseDialog dialog2 = new MessageDialog.Builder(getActivity()).setTitle("温馨提示").setMessage("我是第二个弹出的对话框").setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).create();
        DialogManager.getInstance(this).addShow(dialog1);
        DialogManager.getInstance(this).addShow(dialog2);
    }
}
Also used : UMImage(com.umeng.socialize.media.UMImage) ListPopup(cn.cqautotest.sunnybeach.ui.popup.ListPopup) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick) MenuDialog(cn.cqautotest.sunnybeach.ui.dialog.MenuDialog) PayPasswordDialog(cn.cqautotest.sunnybeach.ui.dialog.PayPasswordDialog) UMWeb(com.umeng.socialize.media.UMWeb) Intent(android.content.Intent) HashMap(java.util.HashMap) Platform(com.hjq.umeng.Platform) ArrayList(java.util.ArrayList) SafeDialog(cn.cqautotest.sunnybeach.ui.dialog.SafeDialog) Calendar(java.util.Calendar) AppActivity(cn.cqautotest.sunnybeach.app.AppActivity) AddressDialog(cn.cqautotest.sunnybeach.ui.dialog.AddressDialog) TipsDialog(cn.cqautotest.sunnybeach.ui.dialog.TipsDialog) View(android.view.View) Button(android.widget.Button) UmengClient(com.hjq.umeng.UmengClient) SelectDialog(cn.cqautotest.sunnybeach.ui.dialog.SelectDialog) DialogManager(cn.cqautotest.sunnybeach.manager.DialogManager) R(cn.cqautotest.sunnybeach.R) InputDialog(cn.cqautotest.sunnybeach.ui.dialog.InputDialog) ShareDialog(cn.cqautotest.sunnybeach.ui.dialog.ShareDialog) TimeDialog(cn.cqautotest.sunnybeach.ui.dialog.TimeDialog) UmengShare(com.hjq.umeng.UmengShare) BaseDialog(com.hjq.base.BaseDialog) MessageDialog(cn.cqautotest.sunnybeach.ui.dialog.MessageDialog) Gravity(android.view.Gravity) DateDialog(cn.cqautotest.sunnybeach.ui.dialog.DateDialog) List(java.util.List) WaitDialog(cn.cqautotest.sunnybeach.ui.dialog.WaitDialog) Nullable(androidx.annotation.Nullable) UpdateDialog(cn.cqautotest.sunnybeach.ui.dialog.UpdateDialog) BaseDialog(com.hjq.base.BaseDialog) Platform(com.hjq.umeng.Platform) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TimeDialog(cn.cqautotest.sunnybeach.ui.dialog.TimeDialog) UMWeb(com.umeng.socialize.media.UMWeb) UpdateDialog(cn.cqautotest.sunnybeach.ui.dialog.UpdateDialog) TipsDialog(cn.cqautotest.sunnybeach.ui.dialog.TipsDialog) ArrayList(java.util.ArrayList) List(java.util.List) MessageDialog(cn.cqautotest.sunnybeach.ui.dialog.MessageDialog) InputDialog(cn.cqautotest.sunnybeach.ui.dialog.InputDialog) ShareDialog(cn.cqautotest.sunnybeach.ui.dialog.ShareDialog) Calendar(java.util.Calendar) UMImage(com.umeng.socialize.media.UMImage) SelectDialog(cn.cqautotest.sunnybeach.ui.dialog.SelectDialog) MenuDialog(cn.cqautotest.sunnybeach.ui.dialog.MenuDialog) AddressDialog(cn.cqautotest.sunnybeach.ui.dialog.AddressDialog) PayPasswordDialog(cn.cqautotest.sunnybeach.ui.dialog.PayPasswordDialog) DateDialog(cn.cqautotest.sunnybeach.ui.dialog.DateDialog) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick)

Example 5 with SingleClick

use of cn.cqautotest.sunnybeach.aop.SingleClick 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

SingleClick (cn.cqautotest.sunnybeach.aop.SingleClick)8 Intent (android.content.Intent)6 View (android.view.View)6 R (cn.cqautotest.sunnybeach.R)6 AppActivity (cn.cqautotest.sunnybeach.app.AppActivity)6 TextUtils (android.text.TextUtils)4 KeyEvent (android.view.KeyEvent)4 AnimationUtils (android.view.animation.AnimationUtils)4 EditorInfo (android.view.inputmethod.EditorInfo)4 Button (android.widget.Button)4 EditText (android.widget.EditText)4 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 GlideApp (cn.cqautotest.sunnybeach.http.glide.GlideApp)4 InputTextManager (cn.cqautotest.sunnybeach.manager.InputTextManager)4 ViewModelProvider (androidx.lifecycle.ViewModelProvider)3 DebugLog (cn.cqautotest.sunnybeach.aop.DebugLog)3 IntentKey (cn.cqautotest.sunnybeach.other.IntentKey)3 Constants (cn.cqautotest.sunnybeach.util.Constants)3 UserViewModel (cn.cqautotest.sunnybeach.viewmodel.UserViewModel)3