fix [换设备已读聊天信息依旧推送问题]
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package com.yunbao.common.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.TextureView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class DebugDialogAdapter extends RecyclerView.Adapter<DebugDialogAdapter.DebugViewHolder> {
|
||||
TreeMap<String, String> paramMap = new TreeMap<>();
|
||||
private Context mContext;
|
||||
|
||||
public DebugDialogAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setParamMap(TreeMap<String, String> paramMap) {
|
||||
this.paramMap = paramMap;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DebugViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new DebugViewHolder(new TextView(mContext));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DebugViewHolder holder, int position) {
|
||||
List<String> list = new ArrayList<>(paramMap.keySet());
|
||||
holder.setData(list.get(position), paramMap.get(list.get(position)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return paramMap.size();
|
||||
}
|
||||
|
||||
public class DebugViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public DebugViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public void setData(String tag, String msg) {
|
||||
((TextView) itemView).setText(tag + ":" + msg);
|
||||
((TextView) itemView).setTextColor(Color.BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.yunbao.common.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.lzf.easyfloat.enums.ShowPattern;
|
||||
import com.lzf.easyfloat.interfaces.OnPermissionResult;
|
||||
import com.lzf.easyfloat.permission.PermissionUtils;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.adapter.DebugDialogAdapter;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
||||
|
||||
public class DebugDialog {
|
||||
RecyclerView recyclerView;
|
||||
TreeMap<String, String> params;
|
||||
DebugDialogAdapter adapter;
|
||||
private static DebugDialog debugDialog;
|
||||
Context mContext;
|
||||
|
||||
public static DebugDialog getInstance(Activity mainActivity) {
|
||||
if (debugDialog == null) {
|
||||
debugDialog = new DebugDialog(mainActivity);
|
||||
}
|
||||
return debugDialog;
|
||||
}
|
||||
|
||||
public DebugDialog clear() {
|
||||
params.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setParams(String tag, String msg) {
|
||||
params.put(tag, msg);
|
||||
if (adapter != null)
|
||||
adapter.setParamMap(params);
|
||||
}
|
||||
|
||||
private DebugDialog(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
params = new TreeMap<>();
|
||||
if (PermissionUtils.checkPermission(mContext)) {
|
||||
createView();
|
||||
} else {
|
||||
PermissionUtils.requestPermission((Activity) mContext, new OnPermissionResult() {
|
||||
@Override
|
||||
public void permissionResult(boolean b) {
|
||||
ToastUtil.show("悬浮权限" + b);
|
||||
if (b) {
|
||||
createView();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void createView() {
|
||||
recyclerView = new RecyclerView(mContext);
|
||||
adapter = new DebugDialogAdapter(mContext);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setBackgroundColor(Color.WHITE);
|
||||
EasyFloat.with(mContext)
|
||||
.setTag("debug")
|
||||
.setShowPattern(ShowPattern.ALL_TIME)
|
||||
.setLayout(recyclerView)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,12 @@ import com.yunbao.common.custom.RatioRoundImageView;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.ViewUtils;
|
||||
|
||||
import io.rong.imkit.utils.RouteUtils;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
|
||||
public class MessageChatNotifyDialog extends AbsDialogPositionPopupWindow {
|
||||
private static boolean dialogStatusShow =false;
|
||||
private MessageUserInfoBean liveBean;
|
||||
private DialogInterface.OnDismissListener onDismissListener;
|
||||
|
||||
@@ -44,6 +43,10 @@ public class MessageChatNotifyDialog extends AbsDialogPositionPopupWindow {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static boolean isDialogStatusShow() {
|
||||
return dialogStatusShow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildDialog(XPopup.Builder builder) {
|
||||
builder.positionByWindowCenter(true);
|
||||
@@ -67,6 +70,13 @@ public class MessageChatNotifyDialog extends AbsDialogPositionPopupWindow {
|
||||
@Override
|
||||
protected void onShow() {
|
||||
super.onShow();
|
||||
dialogStatusShow =true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDismiss() {
|
||||
super.onDismiss();
|
||||
dialogStatusShow =false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -86,7 +86,7 @@ public class MessageSayHiNotifyDialog extends AbsDialogCenterPopupWindow {
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
if(userInfoBean.getId()==0){
|
||||
if (userInfoBean.getId() == 0) {
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
@@ -101,12 +101,12 @@ public class MessageSayHiNotifyDialog extends AbsDialogCenterPopupWindow {
|
||||
anchorName = findViewById(R.id.anchorName);
|
||||
ImgLoader.display(mContext, userInfoBean.getUser().getAvatar(), avatar);
|
||||
anchorName.setText(userInfoBean.getUser().getUserNicename());
|
||||
// ((TextView) findViewById(R.id.description)).setText(userInfoBean.getUser().getSignature());
|
||||
((TextView) findViewById(R.id.description)).setText(WordUtil.isNewZh()?"他就在你附近,來看看~":"He is near you, come and see~");
|
||||
// ((TextView) findViewById(R.id.description)).setText(userInfoBean.getUser().getSignature());
|
||||
((TextView) findViewById(R.id.description)).setText(WordUtil.isNewZh() ? "他就在你附近,來看看~" : "He is near you, come and see~");
|
||||
ViewUtils.findViewById(findViewById(R.id.age), R.id.tag, TextView.class).setText(String.format("%s%s%s",
|
||||
WordUtil.getNewString(R.string.dialog_message_say_hi_age)
|
||||
, userInfoBean.getInfo().getAge()
|
||||
,WordUtil.isNewZh()?"歲":"years old"
|
||||
WordUtil.getNewString(R.string.dialog_message_say_hi_age)
|
||||
, userInfoBean.getInfo().getAge()
|
||||
, WordUtil.isNewZh() ? "歲" : "years old"
|
||||
)
|
||||
);
|
||||
showTag();
|
||||
@@ -115,8 +115,8 @@ public class MessageSayHiNotifyDialog extends AbsDialogCenterPopupWindow {
|
||||
private void showTag() {
|
||||
List<String> tags = new ArrayList<>();
|
||||
tags.add(userInfoBean.getInfo().getSex() == 1 ? WordUtil.getNewString(R.string.sex_male) : WordUtil.getNewString(R.string.sex_female));
|
||||
if (!StringUtil.isEmpty(userInfoBean.getInfo().getCareer())) {
|
||||
tags.add(userInfoBean.getInfo().getCareer());
|
||||
if (!StringUtil.isEmpty(userInfoBean.getInfo().getCareer(), userInfoBean.getInfo().getEnCareer())) {
|
||||
tags.add(WordUtil.isNewZh() ? userInfoBean.getInfo().getCareer() : userInfoBean.getInfo().getEnCareer());
|
||||
}
|
||||
if (!StringUtil.isEmpty(userInfoBean.getInfo().getHeight()) && !userInfoBean.getInfo().getHeight().equals("0")) {
|
||||
tags.add(userInfoBean.getInfo().getHeight());
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.yunbao.common.bean.MessageUserInfoBean;
|
||||
import com.yunbao.common.dialog.DebugDialog;
|
||||
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.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
|
||||
public class MessageChatNotifyManager {
|
||||
private static MessageChatNotifyManager instance;
|
||||
private List<MessageUserInfoBean> startListNotifyList = new ArrayList<>();
|
||||
@@ -34,23 +41,51 @@ public class MessageChatNotifyManager {
|
||||
notifyLiveFlot(mContext);
|
||||
} else {
|
||||
startListNotifyList.add(userInfo);
|
||||
if (!MessageChatNotifyDialog.isDialogStatusShow()) {
|
||||
notifyLiveFlot(mContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyLiveFlot(Context mContext) {
|
||||
public void restart(Context mContext) {
|
||||
notifyLiveFlot(mContext);
|
||||
}
|
||||
|
||||
|
||||
private synchronized void notifyLiveFlot(Context mContext) {
|
||||
String simpleName = AppManager.getInstance().getLastActivity().getClass().getSimpleName();
|
||||
if (clazzList.contains(simpleName)) {
|
||||
ToastUtil.showDebug("屏蔽类,不展示");
|
||||
return;
|
||||
}
|
||||
DebugDialog.getInstance((Activity) mContext).setParams("待推送通知数", startListNotifyList.size() + "");
|
||||
if (startListNotifyList.iterator().hasNext()) {
|
||||
MessageUserInfoBean bean = startListNotifyList.iterator().next();
|
||||
new MessageChatNotifyDialog(AppManager.getInstance().getLastActivity(), bean).setOnDismissListener(dialog -> {
|
||||
startListNotifyList.remove(bean);
|
||||
if (startListNotifyList.iterator().hasNext()) {
|
||||
RongIMClient.getInstance().getUnreadCount(Conversation.ConversationType.PRIVATE, bean.getUser().getId() + "", new RongIMClient.ResultCallback<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer integer) {
|
||||
if (integer > 0) {
|
||||
new MessageChatNotifyDialog(AppManager.getInstance().getLastActivity(), bean).setOnDismissListener(dialog -> {
|
||||
startListNotifyList.remove(bean);
|
||||
if (startListNotifyList.iterator().hasNext()) {
|
||||
notifyLiveFlot(mContext);
|
||||
}
|
||||
}).showDialog();
|
||||
} else {
|
||||
Iterator<MessageUserInfoBean> iterator = startListNotifyList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next().getUser().getId() == bean.getUser().getId()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
notifyLiveFlot(mContext);
|
||||
}
|
||||
}).showDialog();
|
||||
});
|
||||
} else {
|
||||
ToastUtil.showDebug("Not Message");
|
||||
}
|
||||
@@ -71,4 +106,17 @@ public class MessageChatNotifyManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
startListNotifyList.clear();
|
||||
}
|
||||
|
||||
public void clear(long id) {
|
||||
Iterator<MessageUserInfoBean> iterator = startListNotifyList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next().getUser().getId() == id) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
common/src/main/res/layout/dialog_debug.xml
Normal file
11
common/src/main/res/layout/dialog_debug.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user