This commit is contained in:
18401019693 2022-07-28 11:22:16 +08:00
parent 1fc6a3adfe
commit 0cb1ed9b71
6 changed files with 79 additions and 40 deletions

View File

@ -17,7 +17,11 @@ import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import java.util.List;
import io.rong.imkit.IMCenter; import io.rong.imkit.IMCenter;
import io.rong.imkit.MessageItemLongClickAction;
import io.rong.imkit.MessageItemLongClickActionManager;
import io.rong.imlib.RongIMClient; import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Message; import io.rong.imlib.model.Message;
import io.rong.message.RecallNotificationMessage; import io.rong.message.RecallNotificationMessage;
@ -106,6 +110,8 @@ public class MessageLongClickPopuwindow implements View.OnClickListener {
withdrawMethod(); withdrawMethod();
popupWindow.dismiss(); popupWindow.dismiss();
} else if (id == R.id.quote_linear) {//引用 } else if (id == R.id.quote_linear) {//引用
List<MessageItemLongClickAction> messageItemLongClickActionList = MessageItemLongClickActionManager.getInstance().getMessageItemLongClickActions();
Log.e("", messageItemLongClickActionList.size() + "");
} }
} }

View File

@ -16,7 +16,6 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -82,6 +81,13 @@ public class MessageIMManager {
} }
public MessageIMManager setSystemNumber(int systemNumber) {
this.systemNumber = systemNumber;
//发送通知
unreadMessagesHandler.post(essagesRunnable);
return this;
}
/** /**
* 获取系统消息有未读数展示红点 * 获取系统消息有未读数展示红点
*/ */
@ -159,28 +165,6 @@ public class MessageIMManager {
if (callback != null) { if (callback != null) {
callback.onSuccess(code, msg, info); callback.onSuccess(code, msg, info);
} }
if (code == 0) {
List<IMLoginModel> listUserBean = JSON.parseArray(Arrays.toString(info), IMLoginModel.class);
if (listUserBean != null && listUserBean.size() >= 2) {
//目前就三条消息需求判断前两条消息是否有未读消息
for (int i = 0; i < listUserBean.size(); i++) {
//消息对象
IMLoginModel userBean = listUserBean.get(i);
//未读消息数
String number = userBean.getNum();
//未读消息不为空并且大于0
try {
if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) {
systemNumber = Integer.parseInt(number) + systemNumber;
}
} catch (NumberFormatException e) {
systemNumber = systemNumber + 0;
}
}
//发送通知
unreadMessagesHandler.post(essagesRunnable);
}
}
} }
}); });
} }
@ -211,7 +195,7 @@ public class MessageIMManager {
private ConversationClickListener listener = new ConversationClickListener() { private ConversationClickListener listener = new ConversationClickListener() {
@Override @Override
public boolean onUserPortraitClick(Context context, Conversation.ConversationType conversationType, UserInfo userInfo, String targetId) { public boolean onUserPortraitClick(Context context, Conversation.ConversationType conversationType, UserInfo userInfo, String targetId) {
if (!TextUtils.isEmpty(userInfo.getExtra())){ if (!TextUtils.isEmpty(userInfo.getExtra())) {
IMLoginModel model = new Gson().fromJson(userInfo.getExtra(), IMLoginModel.class); IMLoginModel model = new Gson().fromJson(userInfo.getExtra(), IMLoginModel.class);
long userId = IMLoginManager.get(context).getUserInfo().getId(); long userId = IMLoginManager.get(context).getUserInfo().getId();
if (!TextUtils.equals(model.getIsAdmin(), "1") && userId != model.getId()) { if (!TextUtils.equals(model.getIsAdmin(), "1") && userId != model.getId()) {
@ -239,9 +223,9 @@ public class MessageIMManager {
*/ */
@Override @Override
public boolean onMessageLongClick(Context context, View view, Message message) { public boolean onMessageLongClick(Context context, View view, Message message) {
// new MessageLongClickPopuwindow((Activity) context) new MessageLongClickPopuwindow((Activity) context)
// .setMessage(message) .setMessage(message)
// .show(view); .show(view);
return true; return true;
} }

View File

@ -9,9 +9,9 @@ ext {
] ]
manifestPlaceholders = [ manifestPlaceholders = [
// //
serverHost : "https://napi.yaoulive.com", // serverHost : "https://napi.yaoulive.com",
// //
// serverHost : "https://ceshi.yaoulive.com", serverHost : "https://ceshi.yaoulive.com",
// //
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",

View File

@ -79,7 +79,7 @@ public class SystemChatMessageAdapter extends RecyclerView.Adapter {
MessageIMManager.get(mContext).getSystemMessages(new MessageIMManager.SystemMessagesHttpCallback() { MessageIMManager.get(mContext).getSystemMessages(new MessageIMManager.SystemMessagesHttpCallback() {
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
if (code==0){ if (code == 0) {
List<ImUserBean> listUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class); List<ImUserBean> listUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class);
addSystemMessagesView(listUserBean); addSystemMessagesView(listUserBean);
} }
@ -146,5 +146,20 @@ public class SystemChatMessageAdapter extends RecyclerView.Adapter {
listUserBean.addAll(mlistUserBean); listUserBean.addAll(mlistUserBean);
notifyDataSetChanged(); notifyDataSetChanged();
int systemNumber = 0;
for (ImUserBean bean : listUserBean) {
//未读消息数
String number = bean.getNum();
//未读消息不为空并且大于0
try {
if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) {
systemNumber = Integer.parseInt(number) + systemNumber;
}
} catch (NumberFormatException e) {
systemNumber = systemNumber + 0;
}
}
MessageIMManager.get(mContext).setSystemNumber(systemNumber);
} }
} }

View File

@ -3,6 +3,7 @@ package com.yunbao.live.dialog;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -30,6 +31,10 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
super.onBindViewHolder(holder, position); super.onBindViewHolder(holder, position);
Message.MessageDirection messageDirection = mDataList.get(position).getMessage().getMessageDirection(); Message.MessageDirection messageDirection = mDataList.get(position).getMessage().getMessageDirection();
ImageView readReceipt = holder.getConvertView().findViewById(R.id.rc_read_receipt); ImageView readReceipt = holder.getConvertView().findViewById(R.id.rc_read_receipt);
TextView rcEdit = holder.getConvertView().findViewById(R.id.rc_edit);
if (rcEdit!=null){
rcEdit.setVisibility(View.GONE);
}
ImageView readReceiptNew = holder.getConvertView().findViewById(R.id.rc_read_receipt_new); ImageView readReceiptNew = holder.getConvertView().findViewById(R.id.rc_read_receipt_new);
if (readReceiptNew!=null){ if (readReceiptNew!=null){
if (messageDirection==Message.MessageDirection.SEND){ if (messageDirection==Message.MessageDirection.SEND){

View File

@ -3,6 +3,7 @@ package com.yunbao.main.adapter;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Handler;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -37,6 +38,8 @@ public class SystemMessageAdapter extends RecyclerView.Adapter {
private List<ImUserBean> listUserBean = new ArrayList<>(); private List<ImUserBean> listUserBean = new ArrayList<>();
protected Activity mContext; protected Activity mContext;
protected LayoutInflater mInflater; protected LayoutInflater mInflater;
private Handler netHandler = new Handler();
private int mPosition = -1;
public SystemMessageAdapter(Activity mContext) { public SystemMessageAdapter(Activity mContext) {
this.mContext = mContext; this.mContext = mContext;
@ -83,16 +86,8 @@ public class SystemMessageAdapter extends RecyclerView.Adapter {
} }
//系统消息的跳转 //系统消息的跳转
messageViewHolder.setViewHolderOnClickListener((view, model1) -> { messageViewHolder.setViewHolderOnClickListener((view, model1) -> {
//获取一下系统通知 mPosition = position;
MessageIMManager.get(mContext).getSystemMessages(new MessageIMManager.SystemMessagesHttpCallback() { netHandler.post(updataRunable);
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
List<ImUserBean> listUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class);
addSystemMessagesView(listUserBean);
}
}
});
if (model1.getContent().equals("在線客服")) { if (model1.getContent().equals("在線客服")) {
FirebaseAnalytics.getInstance(mContext).logEvent("FS_customer_service", null); FirebaseAnalytics.getInstance(mContext).logEvent("FS_customer_service", null);
AppEventsLogger.newLogger(mContext).logEvent("FB_customer_service"); AppEventsLogger.newLogger(mContext).logEvent("FB_customer_service");
@ -151,8 +146,26 @@ public class SystemMessageAdapter extends RecyclerView.Adapter {
//倒序展示 //倒序展示
Collections.reverse(mlistUserBean); Collections.reverse(mlistUserBean);
listUserBean.clear(); listUserBean.clear();
if (mPosition > 0) {
mlistUserBean.get(mPosition).setNum("");
}
listUserBean.addAll(mlistUserBean); listUserBean.addAll(mlistUserBean);
notifyDataSetChanged(); notifyDataSetChanged();
mPosition = -1;
int systemNumber = 0;
for (ImUserBean bean : listUserBean) {
//未读消息数
String number = bean.getNum();
//未读消息不为空并且大于0
try {
if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) {
systemNumber = Integer.parseInt(number) + systemNumber;
}
} catch (NumberFormatException e) {
systemNumber = systemNumber + 0;
}
}
MessageIMManager.get(mContext).setSystemNumber(systemNumber);
} }
/** /**
@ -177,4 +190,20 @@ public class SystemMessageAdapter extends RecyclerView.Adapter {
} }
notifyDataSetChanged(); notifyDataSetChanged();
} }
private Runnable updataRunable = new Runnable() {
@Override
public void run() {
//获取一下系统通知
MessageIMManager.get(mContext).getSystemMessages(new MessageIMManager.SystemMessagesHttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
List<ImUserBean> listUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class);
addSystemMessagesView(listUserBean);
}
}
});
}
};
} }