use of com.hjq.base.BaseDialog 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 com.hjq.base.BaseDialog in project SunnyBeach by anjiemo.
the class DialogManager method addShow.
/**
* 排队显示 Dialog
*/
public void addShow(BaseDialog dialog) {
if (dialog == null || dialog.isShowing()) {
throw new IllegalStateException("are you ok?");
}
mDialogs.add(dialog);
BaseDialog firstDialog = mDialogs.get(0);
if (!firstDialog.isShowing()) {
firstDialog.addOnDismissListener(this);
firstDialog.show();
}
}
use of com.hjq.base.BaseDialog in project SunnyBeach by anjiemo.
the class DialogManager method clearShow.
/**
* 取消所有 Dialog 的显示
*/
public void clearShow() {
if (mDialogs.isEmpty()) {
return;
}
BaseDialog firstDialog = mDialogs.get(0);
if (firstDialog.isShowing()) {
firstDialog.removeOnDismissListener(this);
firstDialog.dismiss();
}
mDialogs.clear();
}
use of com.hjq.base.BaseDialog in project SunnyBeach by anjiemo.
the class DialogManager method onDismiss.
@Override
public void onDismiss(BaseDialog dialog) {
dialog.removeOnDismissListener(this);
mDialogs.remove(dialog);
for (BaseDialog nextDialog : mDialogs) {
if (!nextDialog.isShowing()) {
nextDialog.addOnDismissListener(this);
nextDialog.show();
break;
}
}
}
Aggregations