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();
}
});
}
}
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());
}
});
}
}
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();
}
}
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);
}
}
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();
}
});
}
}
Aggregations