From 7a5d2b90d806d99be25ff62b844ba9339122527e Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 12 Jun 2024 14:52:30 +0800 Subject: [PATCH] =?UTF-8?q?add[=E6=89=93=E6=8B=9B=E5=91=BC=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E6=98=AF=E5=90=A6=E5=8F=96=E6=B6=88=E5=8F=AF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E5=90=8E=E5=8F=B0=E6=96=B0=E5=A2=9E=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=BC=80=E5=85=B3=E3=80=82]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/bean/MessageSayHiStartBean.java | 15 ++++++ .../dialog/MessageSayHiNotifyDialog.java | 14 +++++- .../utils/MessageSayHiNotifyManager.java | 46 ++++++++++--------- 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/bean/MessageSayHiStartBean.java b/common/src/main/java/com/yunbao/common/bean/MessageSayHiStartBean.java index 1aa44b4d7..4f0b8ac15 100644 --- a/common/src/main/java/com/yunbao/common/bean/MessageSayHiStartBean.java +++ b/common/src/main/java/com/yunbao/common/bean/MessageSayHiStartBean.java @@ -6,6 +6,21 @@ public class MessageSayHiStartBean extends BaseModel{ @SerializedName("time") private int nextTime; private int status; + + @SerializedName("open_off") + private int open_off; + + public int getOpen_off() { + return open_off; + } + + public boolean isCancelDialog(){ + return open_off == 0; + } + public void setOpen_off(int open_off) { + this.open_off = open_off; + } + public int getNextTime() { return nextTime; } diff --git a/common/src/main/java/com/yunbao/common/dialog/MessageSayHiNotifyDialog.java b/common/src/main/java/com/yunbao/common/dialog/MessageSayHiNotifyDialog.java index f4532aaeb..5d7966792 100644 --- a/common/src/main/java/com/yunbao/common/dialog/MessageSayHiNotifyDialog.java +++ b/common/src/main/java/com/yunbao/common/dialog/MessageSayHiNotifyDialog.java @@ -1,5 +1,6 @@ package com.yunbao.common.dialog; +import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Handler; @@ -43,6 +44,8 @@ public class MessageSayHiNotifyDialog extends AbsDialogCenterPopupWindow { private TextView anchorName; private RatioRoundImageView avatar; + private boolean cancelable = true; + public MessageSayHiNotifyDialog(@NonNull Context context) { super(context); @@ -58,9 +61,18 @@ public class MessageSayHiNotifyDialog extends AbsDialogCenterPopupWindow { return this; } + /** + * 设置是否点击其他位置可以关闭弹窗 + */ + public MessageSayHiNotifyDialog setCancelable(boolean cancelable) { + this.cancelable = cancelable; + return this; + } + @Override public void buildDialog(XPopup.Builder builder) { - + builder.dismissOnTouchOutside(cancelable); + builder.dismissOnBackPressed(cancelable); } @Override diff --git a/common/src/main/java/com/yunbao/common/utils/MessageSayHiNotifyManager.java b/common/src/main/java/com/yunbao/common/utils/MessageSayHiNotifyManager.java index d1cdded48..6da99c637 100644 --- a/common/src/main/java/com/yunbao/common/utils/MessageSayHiNotifyManager.java +++ b/common/src/main/java/com/yunbao/common/utils/MessageSayHiNotifyManager.java @@ -28,6 +28,7 @@ public class MessageSayHiNotifyManager { private boolean isStopShow = false; private boolean isShowDialog = false; private boolean isRun = false; + private boolean isCancelDialog = true; private MessageSayHiBean hiBean; private List startListNotifyList = new ArrayList<>(); private String lastActivity; @@ -51,6 +52,7 @@ public class MessageSayHiNotifyManager { Log.i(TAG, "onSuccess: 初始化定时器,定时器关:" + data.toString()); return; } + isCancelDialog = data.isCancelDialog(); timer = new Timer(); timer.schedule(createTask(), data.getNextTime() * 1000L); hiBean = new MessageSayHiBean(); @@ -116,26 +118,27 @@ public class MessageSayHiNotifyManager { Log.i(TAG, "showDialog: 打开本轮打招呼弹框 " + bean); lastActivity = AppManager.getInstance().getLastActivity().getClass().getSimpleName(); new MessageSayHiNotifyDialog(AppManager.getInstance().getLastActivity(), bean.getUser()).setOnDismissListener((userId, position) -> - { - Log.i(TAG, "showDialog: 关闭打招呼弹窗,uid:" + userId + ",是否点击打招呼:" + (position == 2)); - isShowDialog = false; - LiveNetManager.get(AppManager.getInstance().getLastActivity()) - .callBackMessageSayHiTimer(userId, position, new HttpCallback>() { - @Override - public void onSuccess(List data) { + { + Log.i(TAG, "showDialog: 关闭打招呼弹窗,uid:" + userId + ",是否点击打招呼:" + (position == 2)); + isShowDialog = false; + LiveNetManager.get(AppManager.getInstance().getLastActivity()) + .callBackMessageSayHiTimer(userId, position, new HttpCallback>() { + @Override + public void onSuccess(List data) { - } + } - @Override - public void onError(String error) { + @Override + public void onError(String error) { - } - }); + } + }); - Log.i(TAG, "onSuccess: 启动定时器,下一轮时间:" + bean.getNextTime() + "秒"); - timer = new Timer(); - timer.schedule(createTask(), bean.getNextTime() * 1000L); - }).showDialog(); + Log.i(TAG, "onSuccess: 启动定时器,下一轮时间:" + bean.getNextTime() + "秒"); + timer = new Timer(); + timer.schedule(createTask(), bean.getNextTime() * 1000L); + }).setCancelable(isCancelDialog) + .showDialog(); } }); } @@ -207,11 +210,12 @@ public class MessageSayHiNotifyManager { if (startListNotifyList.iterator().hasNext()) { MessageUserInfoBean bean = startListNotifyList.iterator().next(); new MessageSayHiNotifyDialog(AppManager.getInstance().getLastActivity(), bean).setOnDismissListener((bean1, position) -> { - startListNotifyList.remove(bean); - if (startListNotifyList.iterator().hasNext()) { - notifyLiveFlot(mContext); - } - }).showDialog(); + startListNotifyList.remove(bean); + if (startListNotifyList.iterator().hasNext()) { + notifyLiveFlot(mContext); + } + }).setCancelable(isCancelDialog) + .showDialog(); } else { ToastUtil.showDebug("Not Message"); }