75 lines
2.5 KiB
Java
75 lines
2.5 KiB
Java
package com.yunbao.common.utils;
|
|
|
|
import android.content.Context;
|
|
|
|
import com.yunbao.common.bean.MessageUserInfoBean;
|
|
import com.yunbao.common.dialog.MessageChatNotifyDialog;
|
|
import com.yunbao.common.http.base.HttpCallback;
|
|
import com.yunbao.common.http.live.LiveNetManager;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class MessageChatNotifyManager {
|
|
private static MessageChatNotifyManager instance;
|
|
private List<MessageUserInfoBean> startListNotifyList = new ArrayList<>();
|
|
List<String> clazzList = new ArrayList<>();
|
|
|
|
public static MessageChatNotifyManager getInstance() {
|
|
if (instance == null) {
|
|
instance = new MessageChatNotifyManager();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
public void addShieldClass(Class<?> clazz) {
|
|
if (!clazzList.contains(clazz.getSimpleName())) {
|
|
clazzList.add(clazz.getSimpleName());
|
|
}
|
|
}
|
|
|
|
public void push(Context mContext, MessageUserInfoBean userInfo) {
|
|
if (startListNotifyList.isEmpty()) {
|
|
startListNotifyList.add(userInfo);
|
|
notifyLiveFlot(mContext);
|
|
} else {
|
|
startListNotifyList.add(userInfo);
|
|
}
|
|
}
|
|
|
|
private void notifyLiveFlot(Context mContext) {
|
|
String simpleName = AppManager.getInstance().getLastActivity().getClass().getSimpleName();
|
|
if (clazzList.contains(simpleName)) {
|
|
ToastUtil.showDebug("屏蔽类,不展示");
|
|
return;
|
|
}
|
|
if (startListNotifyList.iterator().hasNext()) {
|
|
MessageUserInfoBean bean = startListNotifyList.iterator().next();
|
|
new MessageChatNotifyDialog(AppManager.getInstance().getLastActivity(), bean).setOnDismissListener(dialog -> {
|
|
startListNotifyList.remove(bean);
|
|
if (startListNotifyList.iterator().hasNext()) {
|
|
notifyLiveFlot(mContext);
|
|
}
|
|
}).showDialog();
|
|
} else {
|
|
ToastUtil.showDebug("Not Message");
|
|
}
|
|
}
|
|
|
|
public synchronized void push(Context mContext, String targetId, String content) {
|
|
LiveNetManager.get(mContext)
|
|
.getOtherInfo(targetId, new HttpCallback<MessageUserInfoBean>() {
|
|
@Override
|
|
public void onSuccess(MessageUserInfoBean data) {
|
|
data.setExtras(content);
|
|
push(mContext, data);
|
|
}
|
|
|
|
@Override
|
|
public void onError(String error) {
|
|
|
|
}
|
|
});
|
|
}
|
|
}
|