From 1007e2ab202de1c3d77123e251d526669bde8347 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Mon, 25 Jul 2022 14:06:35 +0800 Subject: [PATCH] 11111 --- common/build.gradle | 7 +-- .../manager/imrongcloud/MessageIMManager.java | 14 +++--- .../live/dialog/PDLiveMessageListAdapter.java | 13 +++--- .../live/views/InputPanelViewHolder.java | 16 ------- .../live/views/LiveAudienceViewHolder.java | 9 ++-- .../res/layout/rc_conversationlist_item.xml | 6 --- .../yunbao/main/activity/LoginActivity.java | 11 ++++- .../yunbao/main/activity/MainActivity.java | 4 +- .../PDLiveConversationListActivity.java | 5 ++- .../ConversationIMListManager.java | 21 +++++---- .../PDLiveCustomConversationProvider.java | 17 +++---- .../main/views/MainHomeLiveViewHolder.java | 44 ------------------- .../yunbao/main/views/MainHomeViewHolder.java | 10 +---- .../res/layout/rc_conversation_fragment.xml | 2 - 14 files changed, 58 insertions(+), 121 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index cf03d4f02..7c307d71f 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -73,6 +73,7 @@ dependencies { api "androidx.constraintlayout:constraintlayout:2.1.4" // To use constraintlayout in compose api "androidx.constraintlayout:constraintlayout-compose:1.0.1" + implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.0' api files('../libs/commons-io-1.4.jar') //okHttp网络请求 api rootProject.ext.dependencies["okhttp"] @@ -150,10 +151,10 @@ dependencies { //腾讯im api 'com.tencent.imsdk:imsdk-plus:5.4.666' api 'com.google.code.gson:gson:2.8.8' - api 'cn.rongcloud.sdk:rtc_lib:5.2.0' // 音视频通话基础能力库 + api 'cn.rongcloud.sdk:rtc_lib:5.2.3.2' // 音视频通话基础能力库 //此处以集成 5.1.2 版本为例 - api 'cn.rongcloud.sdk:im_lib:5.1.3.10' // 即时通讯基础能力库 - api 'cn.rongcloud.sdk:im_kit:5.1.3.10' // 即时通讯 UI 基础组件 + api 'cn.rongcloud.sdk:im_lib:5.2.3.2' // 即时通讯基础能力库 + api 'cn.rongcloud.sdk:im_kit:5.2.3.2' // 即时通讯 UI 基础组件 api 'com.facebook.android:facebook-login:8.2.0' api 'com.facebook.android:facebook-android-sdk:[5,6)' diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java index 1c2484c15..a1b534f65 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java @@ -83,6 +83,7 @@ public class MessageIMManager { * 获取系统消息(有未读数展示红点) */ public void getSystemMessages() { + systemNumber=0; IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); HttpClient.getInstance().get("Message.getLists", "getImUserInfo") .params("uid", userInfo.getId()) @@ -102,12 +103,10 @@ public class MessageIMManager { //未读消息不为空并且大于0 try { if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) { - systemNumber = Integer.parseInt(number); - } else { - systemNumber = 0; + systemNumber = Integer.parseInt(number)+systemNumber; } } catch (NumberFormatException e) { - systemNumber = 0; + systemNumber =systemNumber+ 0; } } //发送通知 @@ -146,6 +145,7 @@ public class MessageIMManager { * 获取系统消息(有未读数展示红点) */ public void getSystemMessages(SystemMessagesHttpCallback callback) { + systemNumber=0; IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); HttpClient.getInstance().get("Message.getLists", "getImUserInfo") .params("uid", userInfo.getId()) @@ -168,12 +168,10 @@ public class MessageIMManager { //未读消息不为空并且大于0 try { if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) { - systemNumber = Integer.parseInt(number); - } else { - systemNumber = 0; + systemNumber = Integer.parseInt(number)+systemNumber; } } catch (NumberFormatException e) { - systemNumber = 0; + systemNumber = systemNumber+0; } } //发送通知 diff --git a/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java b/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java index 7fc26cb6e..988618f7a 100644 --- a/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java +++ b/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java @@ -29,20 +29,21 @@ public class PDLiveMessageListAdapter extends MessageListAdapter { public void onBindViewHolder(@NonNull ViewHolder holder, int position) { super.onBindViewHolder(holder, position); Message.MessageDirection messageDirection = mDataList.get(position).getMessage().getMessageDirection(); - Message.SentStatus sentStatus = mDataList.get(position).getMessage().getSentStatus(); ImageView readReceipt = holder.getConvertView().findViewById(R.id.rc_read_receipt); - readReceipt.setVisibility(View.GONE); ImageView readReceiptNew = holder.getConvertView().findViewById(R.id.rc_read_receipt_new); - if (!mDataList.get(position).getMessage().getSenderUserId().equals(mDataList.get(position).getTargetId())) { - if (sentStatus.equals(Message.SentStatus.READ)) { + if (messageDirection==Message.MessageDirection.SEND){ + readReceiptNew.setVisibility(View.VISIBLE); + }else { + readReceiptNew.setVisibility(View.GONE); + } + if (readReceipt.getVisibility()==View.VISIBLE) { readReceiptNew.setBackgroundResource(R.mipmap.icon_message_read); } else { readReceiptNew.setBackgroundResource(R.mipmap.icon_message_unread); } - } else { + if (readReceipt!=null){ readReceipt.setVisibility(View.GONE); } - holder.getConvertView().setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { diff --git a/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java b/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java index 10c5036bb..0a928d7f2 100644 --- a/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java @@ -78,24 +78,8 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi inputPanelView.findViewById(R.id.lt_photo_button).setOnClickListener(this); inputPanelView.findViewById(R.id.lt_choospic_button).setOnClickListener(this); inputPanelView.findViewById(R.id.lt_video_button).setOnClickListener(this); -// editBtn.setOnFocusChangeListener(focusChangeListener); } -// //输入框焦点监听事件 -// View.OnFocusChangeListener focusChangeListener = new OnFocusChangeListener() { -// @Override -// public void onFocusChange(View v, boolean hasFocus) { -// if (!hasFocus&& pluginList.getVisibility()==GONE) { -// //失去焦点 -// InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); -// imm.showSoftInput(editBtn, InputMethodManager.SHOW_FORCED); -// imm.hideSoftInputFromWindow(editBtn.getWindowToken(), 0); //强制隐藏键盘 -// } else { -// pluginList.setVisibility(GONE); -// } -// } -// }; - @Override public void onClick(View v) { int id = v.getId(); diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index d236ed887..58aaeec93 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -16,6 +16,7 @@ import android.widget.TextView; import com.alibaba.fastjson.JSONObject; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; +import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.event.UpdateTablePoint; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; @@ -355,11 +356,11 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { } - //红点(直播页面) - @Subscribe(threadMode = ThreadMode.MAIN) - public void onUpdateFieldEvent(UpdateTablePoint updateTablePoint) { + //消息中心 + @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) + public void onMessageIMEvent(MessageIMEvent event) { //判断消息中心红点是否已经展示,如果已经展示并且未读消息大于0则不再执行之后的逻辑 - int number = updateTablePoint.getPoint(); + int number = event.getNumber(); if (v_msg_redpoint.getVisibility() == View.VISIBLE && number > 0) return; if (number > 0) { v_msg_redpoint.setVisibility(View.VISIBLE); diff --git a/live/src/main/res/layout/rc_conversationlist_item.xml b/live/src/main/res/layout/rc_conversationlist_item.xml index 0e63cb8fa..599a5ba56 100644 --- a/live/src/main/res/layout/rc_conversationlist_item.xml +++ b/live/src/main/res/layout/rc_conversationlist_item.xml @@ -62,12 +62,6 @@ android:layout_marginStart="15dp" android:layout_marginEnd="4dp" /> - 0&&!TextUtils.equals("__system__",userId)) { + if (code == 0 && info.length > 0 && !TextUtils.equals("__system__", userId)) { JSONObject obj = JSON.parseObject(info[0]); SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class); String userNiceName = ""; @@ -159,6 +156,9 @@ public class ConversationIMListManager { return false; } + /** + * 长按时间 + */ @Override public boolean onConversationLongClick(Context context, View view, BaseUiConversation baseUiConversation) { new ConversationPopuwWindow((Activity) context) @@ -167,9 +167,14 @@ public class ConversationIMListManager { return true; } + /** + * 点击 + * @return + */ @Override public boolean onConversationClick(Context context, View view, BaseUiConversation baseUiConversation) { - return false; + jumpConversation((Activity) context, baseUiConversation.mCore.getTargetId()); + return true; } }; diff --git a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java index 5d73a3316..60b881f13 100644 --- a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java +++ b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java @@ -38,23 +38,16 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider { public void bindViewHolder(ViewHolder holder, BaseUiConversation uiConversation, int position, List list, IViewProviderListener listener) { //根据业务需要,自定义处理 super.bindViewHolder(holder, uiConversation, position, list, listener); - if (list.size() > 0) { - Message.SentStatus sentStatus = list.get(position).mCore.getSentStatus(); - ImageView readReceipt = holder.itemView.findViewById(com.yunbao.live.R.id.rc_read_receipt_new); - View rcMargin = holder.itemView.findViewById(com.yunbao.live.R.id.rc_margin); - if (TextUtils.equals(list.get(position).mCore.getSenderUserId(), list.get(position).mCore.getTargetId())) { - readReceipt.setVisibility(View.GONE); - rcMargin.setVisibility(View.VISIBLE); - } + ImageView readReceipt = holder.itemView.findViewById(com.yunbao.live.R.id.rc_read_receipt_new); + if (uiConversation.mCore.getLatestMessageDirection()==Message.MessageDirection.SEND) { + Message.SentStatus sentStatus = uiConversation.mCore.getSentStatus(); if (sentStatus == Message.SentStatus.READ) { readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_messagelist_read); } else { readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_messagelist_unread); } - - + }else { + readReceipt.setVisibility(View.GONE); } - - } } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java index 0e1845daa..a5ede55cd 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java @@ -211,48 +211,6 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement } return new_data; -// if (select == 0) { -// JSONObject obj = JSON.parseObject(info[0]); -// mBannerList = JSON.parseArray(obj.getString("slide"), BannerBean.class); -// List old_data = JSON.parseArray(obj.getString("list"), LiveBean.class); -// new_data = new ArrayList<>(); -// if (old_data != null) { -// for (int j = 0; j < old_data.size(); j++) { -// new_data.add(old_data.get(j)); -// if (j == 3) { -// LiveBean liveBean = new LiveBean(); -// liveBean.setIsTop("1"); -// new_data.add(liveBean); -// } -// } -// } -// if (!isHave) { -// if (new_data.size() > 5) { -// new_data.remove(5); -// } -// } else { -// if (mWeekListBean != null) { -// if (new_data.size() > 5) { -// new_data.get(5).setmWeekList(mWeekListBean); -// } -// } -// } -// return new_data; -// } else { -// List old_data = JSON.parseArray(Arrays.toString(info), LiveBean.class); -// new_data = new ArrayList<>(); -// for (int j = 0; j < old_data.size(); j++) { -// new_data.add(old_data.get(j)); -// if (j == 3) { -// LiveBean liveBean = new LiveBean(); -// liveBean.setIsTop("1"); -// new_data.add(liveBean); -// } -// } -// return new_data; -// } - -// } } @Override @@ -286,11 +244,9 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement } }); -// if (headView != null) { mClassRecyclerViewTop = (RecyclerView) findViewById(R.id.classRecyclerView_top); mClassRecyclerViewTop.setHasFixedSize(true); mClassRecyclerViewTop.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false)); -// } ConfigBean configBean = CommonAppConfig.getInstance().getConfig(); if (configBean != null) { List list = configBean.getLiveClass(); diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java index bbc853197..834025436 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java @@ -1,12 +1,10 @@ package com.yunbao.main.views; import android.content.Context; -import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; -import com.yunbao.common.HtmlConfig; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.utils.WordUtil; import com.yunbao.main.R; @@ -59,15 +57,11 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { } else if (position == 1) { mainHomeLiveViewHolder = new MainHomeLiveViewHolder(mContext, parent); vh = mainHomeLiveViewHolder; - } - else if (position == 2) { + } else if (position == 2) { mainHomeRecomLiveViewHolder = new MainHomeRecomLiveViewHolder(mContext, parent); vh = mainHomeRecomLiveViewHolder; } -// else if (position == 3) { -// mCsdViewHolder = new MainHomeCsdViewHolder(mContext, parent); -// vh = mCsdViewHolder; -// } + if (vh == null) { return; } diff --git a/main/src/main/res/layout/rc_conversation_fragment.xml b/main/src/main/res/layout/rc_conversation_fragment.xml index 35a874b22..23a8fa31b 100644 --- a/main/src/main/res/layout/rc_conversation_fragment.xml +++ b/main/src/main/res/layout/rc_conversation_fragment.xml @@ -45,7 +45,6 @@ android:layout_marginStart="3dp" android:layout_marginTop="@dimen/rc_margin_size_30" android:layout_marginEnd="5dp" - android:background="@drawable/rc_selector_item_unread" android:drawableStart="@drawable/rc_unread_msg_arrow" android:drawablePadding="10dp" android:gravity="center|left" @@ -67,7 +66,6 @@ android:layout_marginStart="3dp" android:layout_marginTop="@dimen/rc_margin_size_80" android:layout_marginEnd="5dp" - android:background="@drawable/rc_selector_item_unread" android:drawableStart="@drawable/rc_unread_msg_arrow" android:drawablePadding="10dp" android:gravity="center|left"