This commit is contained in:
18401019693 2022-07-23 16:31:33 +08:00
parent 18aabb85a7
commit cc35227b56
26 changed files with 603 additions and 113 deletions

View File

@ -0,0 +1,141 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
/**
* r融雲發送的系統消息通知
*/
public class ImUserInfoModel extends BaseModel {
@SerializedName("title")
String title;//
@SerializedName("image")
String image;//头像
@SerializedName("content")
String content;//最新一条内容
@SerializedName("addtime")
String addtime;//最后时间
@SerializedName("num")
String num;//未读消息数
@SerializedName("link")
String link;//跳转连接
@SerializedName("type")
String type;//
@SerializedName("userId")
String userId;//单聊的id
@SerializedName("remarks")
String remarks;//备注的信息
@SerializedName("is_admin")
String isAdmin;
@SerializedName("isDelet")
String isDelet;
@SerializedName("_method_")
String method="";//融雲消息類型
public String getTitle() {
return title;
}
public ImUserInfoModel setTitle(String title) {
this.title = title;
return this;
}
public String getImage() {
return image;
}
public ImUserInfoModel setImage(String image) {
this.image = image;
return this;
}
public String getContent() {
return content;
}
public ImUserInfoModel setContent(String content) {
this.content = content;
return this;
}
public String getAddtime() {
return addtime;
}
public ImUserInfoModel setAddtime(String addtime) {
this.addtime = addtime;
return this;
}
public String getNum() {
return num;
}
public ImUserInfoModel setNum(String num) {
this.num = num;
return this;
}
public String getLink() {
return link;
}
public ImUserInfoModel setLink(String link) {
this.link = link;
return this;
}
public String getType() {
return type;
}
public ImUserInfoModel setType(String type) {
this.type = type;
return this;
}
public String getUserId() {
return userId;
}
public ImUserInfoModel setUserId(String userId) {
this.userId = userId;
return this;
}
public String getRemarks() {
return remarks;
}
public ImUserInfoModel setRemarks(String remarks) {
this.remarks = remarks;
return this;
}
public String getIsAdmin() {
return isAdmin;
}
public ImUserInfoModel setIsAdmin(String isAdmin) {
this.isAdmin = isAdmin;
return this;
}
public String getIsDelet() {
return isDelet;
}
public ImUserInfoModel setIsDelet(String isDelet) {
this.isDelet = isDelet;
return this;
}
public String getMethod() {
return method;
}
public ImUserInfoModel setMethod(String method) {
this.method = method;
return this;
}
}

View File

@ -3,21 +3,30 @@ package com.yunbao.common.manager.imrongcloud;
import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.ImUserInfoModel;
import com.yunbao.common.event.MessageIMEvent;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.ToastUtil;
import org.greenrobot.eventbus.EventBus;
import java.util.Arrays;
import java.util.List;
import io.rong.imkit.IMCenter;
import io.rong.imkit.config.ConversationClickListener;
import io.rong.imkit.manager.UnReadMessageManager;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.imlib.model.UserInfo;
import io.rong.message.TextMessage;
/**
* 消息的监听管理
@ -85,7 +94,7 @@ public class MessageIMManager {
List<IMLoginModel> listUserBean = JSON.parseArray(Arrays.toString(info), IMLoginModel.class);
if (listUserBean != null && listUserBean.size() >= 2) {
//目前就三条消息需求判断前两条消息是否有未读消息
for (int i = 0; i < listUserBean.size() - 2; i++) {
for (int i = 0; i < listUserBean.size(); i++) {
//消息对象
IMLoginModel userBean = listUserBean.get(i);
//未读消息数
@ -109,6 +118,30 @@ public class MessageIMManager {
});
}
/**
* 融雲發送的系統消息
*
* @param message
*/
public void getSystemForRongcloud(Message message) {
ImUserInfoModel model = null;
if ((message.getConversationType() == Conversation.ConversationType.SYSTEM) && (message.getContent() instanceof TextMessage)) {
TextMessage content = (TextMessage) message.getContent();
String json = content.getContent();
model = new Gson().fromJson(json, ImUserInfoModel.class);
}
if (message.getConversationType() == Conversation.ConversationType.SYSTEM && model != null && TextUtils.equals(model.getMethod(), "LivePK_UnreadCount")) {
//发送通知
EventBus.getDefault().post(model);
try {
systemNumber = systemNumber + 1;
unreadMessagesHandler.post(essagesRunnable);
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
}
/**
* 获取系统消息有未读数展示红点
*/
@ -127,7 +160,7 @@ public class MessageIMManager {
List<IMLoginModel> listUserBean = JSON.parseArray(Arrays.toString(info), IMLoginModel.class);
if (listUserBean != null && listUserBean.size() >= 2) {
//目前就三条消息需求判断前两条消息是否有未读消息
for (int i = 0; i < listUserBean.size() - 2; i++) {
for (int i = 0; i < listUserBean.size(); i++) {
//消息对象
IMLoginModel userBean = listUserBean.get(i);
//未读消息数
@ -164,4 +197,50 @@ public class MessageIMManager {
EventBus.getDefault().post(new MessageIMEvent().setNumber(number));
};
/**
* 设置会话界面操作监听器
*/
public void addConversationClickListener() {
IMCenter.setConversationClickListener(listener);
}
/**
* 会话界面操作监听器
*/
private ConversationClickListener listener = new ConversationClickListener() {
@Override
public boolean onUserPortraitClick(Context context, Conversation.ConversationType conversationType, UserInfo userInfo, String s) {
return false;
}
@Override
public boolean onUserPortraitLongClick(Context context, Conversation.ConversationType conversationType, UserInfo userInfo, String s) {
return false;
}
@Override
public boolean onMessageClick(Context context, View view, Message message) {
return false;
}
/**
* 长按消息时
*/
@Override
public boolean onMessageLongClick(Context context, View view, Message message) {
ToastUtil.show(message.getContent().toString());
return true;
}
@Override
public boolean onMessageLinkClick(Context context, String s, Message message) {
return false;
}
@Override
public boolean onReadReceiptStateClick(Context context, Message message) {
return false;
}
};
}

View File

@ -827,4 +827,5 @@
<string name="live_hot_ruletext22">前往「個人中心」-「我的包裹」中,即可使用熱度卡。</string>
<string name="live_hot_ruletext31">熱度卡生效多久?</string>
<string name="live_hot_ruletext32">對指定主播使用熱度卡後將會立即生效效果時長為24小時不管主播是否在線熱度時長都將會持續減少</string>
<string name="quote">引用</string>
</resources>

View File

@ -9,9 +9,9 @@ ext {
]
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",

View File

@ -76,21 +76,20 @@
<activity
android:name=".activity.LiveRyAnchorActivity"
android:screenOrientation="portrait" />
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
<activity
android:name=".activity.PDLiveConversationActivity"
android:hardwareAccelerated="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden">
</activity>
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"/>
<activity
android:name=".activity.PDLIiveChatActivity"
android:screenOrientation="portrait"
android:theme="@style/DialogActivity"
android:windowSoftInputMode="stateHidden|adjustResize">
</activity>
android:theme="@style/DialogActivity"/>
<activity
android:name=".activity.EditNameRemarksActivity"
android:screenOrientation="portrait" />

View File

@ -23,9 +23,12 @@ import com.yunbao.common.activity.SelectImageActivity;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.ImageEntity;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.live.R;
import com.yunbao.live.bean.SearchUserBean;
import com.yunbao.live.dialog.MenuPopuwWindow;
import com.yunbao.live.event.InputPanelViewHolderEvent;
import com.yunbao.live.utils.WindowSoftModeAdjustResizeExecutor;
import com.yunbao.live.views.InputPanelViewHolder;
import com.yunbao.live.views.PDLiveConversationFragment;
@ -65,9 +68,12 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
super.main();
EventBus.getDefault().register(this);
mContext = this;
// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
initView();
initData();
WindowSoftModeAdjustResizeExecutor.assistActivity(this);
//设置会话界面操作监听器
MessageIMManager.get(this).addConversationClickListener();
}
/**
@ -79,6 +85,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
inputPanel.setTargetId(targetId);
//获取用户信息
UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId);
if (null!=userInfo){
titleView.setText(userInfo.getName());
if (!TextUtils.isEmpty(userInfo.getExtra())) {
SearchUserBean userBean = GsonUtils.fromJson(userInfo.getExtra(), SearchUserBean.class);
@ -92,6 +99,11 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
}
Log.e("PDLiveConversation", userInfo.getExtra());
}
}else {
titleView.setText("系統消息");
inputPanel.setVisibility(View.GONE);
}
}
@ -204,4 +216,13 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
titleView.setText(event);
}
}
//消息中心
@Subscribe(threadMode = ThreadMode.MAIN)
public void onInputPanelViewHolderEvent(InputPanelViewHolderEvent event) {
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
inputPanel.hidePluginList();
}
}

View File

@ -1,11 +1,8 @@
package com.yunbao.live.bean;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import com.alibaba.fastjson.annotation.JSONField;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.BaseModel;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -15,7 +12,8 @@ import java.util.Date;
* IM 聊天用户 实体类
*/
public class ImUserBean {
public class ImUserBean extends BaseModel {
String title;//
String image;//头像
@ -28,93 +26,114 @@ public class ImUserBean {
String remarks;//备注的信息
String is_admin;
String isDelet;
public String getIsDelet() {
return isDelet;
}
public void setIsDelet(String isDelet) {
this.isDelet = isDelet;
}
public String getIs_admin() {
return is_admin;
}
public void setIs_admin(String is_admin) {
this.is_admin = is_admin;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
String _method_ = "";//融雲消息類型
public String getTitle() {
return title;
}
public void setTitle(String title) {
public ImUserBean setTitle(String title) {
this.title = title;
return this;
}
public String getImage() {
return image;
}
public void setImage(String image) {
public ImUserBean setImage(String image) {
this.image = image;
return this;
}
public String getContent() {
return content;
}
public void setContent(String content) {
public ImUserBean setContent(String content) {
this.content = content;
return this;
}
public String getAddtime() {
return addtime;
}
public void setAddtime(String addtime) {
public ImUserBean setAddtime(String addtime) {
this.addtime = addtime;
return this;
}
public String getNum() {
return num;
}
public void setNum(String num) {
public ImUserBean setNum(String num) {
this.num = num;
return this;
}
public String getLink() {
return link;
}
public void setLink(String link) {
public ImUserBean setLink(String link) {
this.link = link;
return this;
}
public String getType() {
return type;
}
public void setType(String type) {
public ImUserBean setType(String type) {
this.type = type;
return this;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
public ImUserBean setUserId(String userId) {
this.userId = userId;
return this;
}
public String getRemarks() {
return remarks;
}
public ImUserBean setRemarks(String remarks) {
this.remarks = remarks;
return this;
}
public String getIs_admin() {
return is_admin;
}
public ImUserBean setIs_admin(String is_admin) {
this.is_admin = is_admin;
return this;
}
public String getIsDelet() {
return isDelet;
}
public ImUserBean setIsDelet(String isDelet) {
this.isDelet = isDelet;
return this;
}
public String get_method_() {
return _method_;
}
public ImUserBean set_method_(String _method_) {
this._method_ = _method_;
return this;
}
/**
@ -135,4 +154,18 @@ public class ImUserBean {
}
}
public String addNumber(int index) {
String number;
if (TextUtils.isEmpty(num)) {
number = String.valueOf(index);
} else {
try {
number = String.valueOf(Integer.parseInt(num) + index);
} catch (NumberFormatException e) {
number = String.valueOf(index);
}
}
return number;
}
}

View File

@ -0,0 +1,26 @@
package com.yunbao.live.dialog;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;
import com.yunbao.live.R;
/**
* 消息長按彈窗
*/
public class MessageLongClickPopuwindow {
private Activity mContext;
private View popupView;
private PopupWindow popupWindow;
public MessageLongClickPopuwindow(Activity context) {
this.mContext = context;
popupView = LayoutInflater.from(mContext).inflate(R.layout.view_message_long_click, null);
initView();
}
private void initView() {
}
}

View File

@ -1,11 +1,15 @@
package com.yunbao.live.dialog;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import com.yunbao.live.R;
import com.yunbao.live.event.InputPanelViewHolderEvent;
import org.greenrobot.eventbus.EventBus;
import io.rong.imkit.conversation.MessageListAdapter;
import io.rong.imkit.model.UiMessage;
@ -37,6 +41,13 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_unread);
}
}
holder.getConvertView().setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//消費掉軟件盤和插件頁面
EventBus.getDefault().post(new InputPanelViewHolderEvent());
return true;
}
});
}
}

View File

@ -0,0 +1,9 @@
package com.yunbao.live.event;
import com.yunbao.common.bean.BaseModel;
/**
* 點擊聊天列表的消費
*/
public class InputPanelViewHolderEvent extends BaseModel {
}

View File

@ -0,0 +1,48 @@
package com.yunbao.live.utils;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import android.widget.FrameLayout;
public class WindowSoftModeAdjustResizeExecutor {
// For more information, see https://code.google.com/p/android/issues/detail?id=5497
// To use this class, simply invoke assistActivity() on an Activity that already has its content view set.
// CREDIT TO Joseph Johnson (http://stackoverflow.com/users/341631/joseph-johnson) for publishing the original Android solution on stackoverflow.com
public static void assistActivity(Activity activity) {
new WindowSoftModeAdjustResizeExecutor(activity);
}
private View mChildOfContent;
private int usableHeightPrevious;
private FrameLayout.LayoutParams frameLayoutParams;
private WindowSoftModeAdjustResizeExecutor(Activity activity) {
FrameLayout content = activity.findViewById(android.R.id.content);
mChildOfContent = content.getChildAt(0);
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(() -> WindowSoftModeAdjustResizeExecutor.this.possiblyResizeChildOfContent());
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
}
private void possiblyResizeChildOfContent() {
int usableHeightNow = computeUsableHeight();
if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
}
}
private int computeUsableHeight() {
Rect r = new Rect();
mChildOfContent.getWindowVisibleDisplayFrame(r);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return (r.bottom - r.top);
}
return r.bottom;
}
}

View File

@ -78,21 +78,23 @@ 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);
// editBtn.setOnFocusChangeListener(focusChangeListener);
}
//输入框焦点监听事件
View.OnFocusChangeListener focusChangeListener = new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
//失去焦点
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editBtn, InputMethodManager.SHOW_FORCED);
imm.hideSoftInputFromWindow(editBtn.getWindowToken(), 0); //强制隐藏键盘
}
}
};
// //输入框焦点监听事件
// 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) {
@ -106,6 +108,7 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
} else if (id == R.id.edit_btn) {
if (pluginList.getVisibility() == VISIBLE) {
pluginList.setVisibility(GONE);
editBtn.setFocusable(true);
}
} else if (id == R.id.lt_photo_button) {
if (messageCallback != null) {
@ -129,11 +132,11 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
if (pluginList.getVisibility() == VISIBLE) {
pluginList.setVisibility(GONE);
} else {
pluginList.setVisibility(VISIBLE);
//失去焦点
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editBtn, InputMethodManager.SHOW_FORCED);
imm.hideSoftInputFromWindow(editBtn.getWindowToken(), 0); //强制隐藏键盘
pluginList.setVisibility(VISIBLE);
}
}
@ -205,7 +208,7 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
};
/**
* 发送媒体消息
* 发送媒体消息 隱藏
*
* @param imagePath
*/
@ -303,4 +306,11 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
messageCallback = callback;
}
/**
* 隱藏插件列表
*/
public void hidePluginList() {
pluginList.setVisibility(GONE);
}
}

View File

@ -74,13 +74,14 @@
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
android:gravity="center_vertical"
app:layout_constraintStart_toEndOf="@+id/rc_conversation_portrait_rl"
app:layout_constraintTop_toBottomOf="@+id/rc_conversation_title">
<ImageView
android:id="@+id/rc_read_receipt_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="30dp"
android:layout_height="15dp"
android:layout_gravity="bottom"
android:layout_marginStart="15dp"
android:layout_marginEnd="4dp" />

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:cardBackgroundColor="#474747"
app:cardCornerRadius="12dp"
app:cardElevation="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@mipmap/icon_message_copy"
android:drawablePadding="5dp"
android:text="@string/copy"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@mipmap/icon_message_copy"
android:drawablePadding="5dp"
android:text="@string/withdraw"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@mipmap/icon_message_quote"
android:drawablePadding="5dp"
android:text="@string/quote"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -37,12 +37,10 @@ import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMSDKConfig;
import com.tencent.imsdk.v2.V2TIMSDKListener;
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.adapter.ViewPagerAdapter;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.ChatRemarksBean;
import com.yunbao.common.bean.ConfigBean;
import com.yunbao.common.bean.LiveSvgGiftBean;
@ -56,6 +54,7 @@ import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
@ -72,7 +71,6 @@ import com.yunbao.common.views.AbsMainViewHolder;
import com.yunbao.live.LiveConfig;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.PDLIiveChatActivity;
import com.yunbao.live.bean.LiveBean;
import com.yunbao.live.bean.LiveKsyConfigBean;
import com.yunbao.live.http.LiveHttpConsts;
@ -115,10 +113,8 @@ import java.util.Map;
import cn.rongcloud.rtc.api.RCRTCConfig;
import cn.rongcloud.rtc.api.RCRTCEngine;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.message.TextMessage;
import static com.yunbao.common.CommonAppContext.Ingroup;
import static com.yunbao.common.CommonAppContext.isReady;
public class MainActivity extends AbsActivity implements MainAppBarLayoutListener {
@ -365,6 +361,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Override
public boolean onReceived(io.rong.imlib.model.Message message, int i, boolean b, boolean b1) {
Log.e("wewe", message.getConversationType() + "112121");
MessageIMManager.get(mContext).getSystemForRongcloud(message);
//融云直播间聊天
Message msg = Message.obtain();
msg.what = Constants.SOCKET_WHAT_BROADCAST;
@ -1074,8 +1071,13 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
public void onMessageIMEvent(MessageIMEvent event) {
messageNumber = event.getNumber();
if (event.getNumber() > 0) {
v_table_redpoint.setVisibility(View.VISIBLE);
if (event.getNumber() > 99) {
v_table_redpoint.setText("99+");
} else {
v_table_redpoint.setText(event.getNumber() + "");
}
v_table_redpoint.setVisibility(View.VISIBLE);
} else {
v_table_redpoint.setVisibility(View.GONE);
v_table_redpoint.setText("");

View File

@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.bean.ImUserInfoModel;
import com.yunbao.common.custom.TabButtonGroup;
import com.yunbao.common.event.MessageIMEvent;
import com.yunbao.common.event.UpdateTablePointMe;
@ -51,6 +52,7 @@ public class PDLiveConversationListActivity extends AbsActivity {
private long mLastClickBackTime;//上次点击back键的时间
private TextView redPoint;
private View redpointMe;
private SystemMessageAdapter messageAdapter;
@Override
protected int getLayoutId() {
@ -143,7 +145,7 @@ public class PDLiveConversationListActivity extends AbsActivity {
//初始化系统消息界面
View rootView = LayoutInflater.from(mContext).inflate(R.layout.view_system_message, null, true);
RecyclerView systemMessageList = rootView.findViewById(R.id.system_message_list);
SystemMessageAdapter messageAdapter = new SystemMessageAdapter(mContext);
messageAdapter = new SystemMessageAdapter(mContext);
messageAdapter.addDataAll(listUserBean);
systemMessageList.setHasFixedSize(false);
systemMessageList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, true));
@ -201,8 +203,13 @@ public class PDLiveConversationListActivity extends AbsActivity {
public void onMessageIMEvent(MessageIMEvent event) {
if (redPoint == null) return;
if (event.getNumber() > 0) {
redPoint.setVisibility(View.VISIBLE);
if (event.getNumber() > 99) {
redPoint.setText(String.valueOf("99+"));
} else {
redPoint.setText(String.valueOf(event.getNumber()));
}
redPoint.setVisibility(View.VISIBLE);
} else {
redPoint.setVisibility(View.GONE);
redPoint.setText("");
@ -219,4 +226,10 @@ public class PDLiveConversationListActivity extends AbsActivity {
redpointMe.setVisibility(View.GONE);
}
}
//更新系統消息
@Subscribe(threadMode = ThreadMode.MAIN)
public void onImUserInfoModel(ImUserInfoModel model) {
messageAdapter.upDataMessage(model);
}
}

View File

@ -17,6 +17,7 @@ import com.alibaba.fastjson.JSON;
import com.facebook.appevents.AppEventsLogger;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.ImUserInfoModel;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.live.activity.SystemMessageActivity;
@ -55,7 +56,7 @@ public class SystemMessageAdapter extends RecyclerView.Adapter {
SystemMessageViewHolder messageViewHolder = (SystemMessageViewHolder) holder;
ImgLoader.displayWithError(mContext, model.getImage(), messageViewHolder.avatarImage, com.yunbao.live.R.mipmap.chat_head_mo);
if (position == 2) {
messageViewHolder.userMsg.setText(TextUtils.isEmpty(model.getLink()) ? mContext.getResources().getString(R.string.chat_like) : model.getLink());
messageViewHolder.userMsg.setText(TextUtils.isEmpty(model.getContent()) ? mContext.getResources().getString(R.string.chat_like) : model.getContent());
} else {
if (position == 1) {
messageViewHolder.userMsg.setText(TextUtils.isEmpty(model.getContent()) ? mContext.getResources().getString(R.string.chat_action_no) : model.getContent());
@ -68,8 +69,15 @@ public class SystemMessageAdapter extends RecyclerView.Adapter {
String number = model.getNum();
if (!TextUtils.isEmpty(number) && !TextUtils.equals(number, "0")) {
messageViewHolder.redPoint.setVisibility(View.VISIBLE);
int index = Integer.parseInt(number);
if (index > 99) {
messageViewHolder.redPoint.setText("99+");
} else {
messageViewHolder.redPoint.setText(number);
}
messageViewHolder.redPoint.setVisibility(View.VISIBLE);
} else {
messageViewHolder.redPoint.setVisibility(View.GONE);
}
@ -145,6 +153,28 @@ public class SystemMessageAdapter extends RecyclerView.Adapter {
listUserBean.clear();
listUserBean.addAll(mlistUserBean);
notifyDataSetChanged();
}
/**
* 更新系統數據
*/
public void upDataMessage(ImUserInfoModel model) {
for (ImUserBean imUserBean : listUserBean) {
if (TextUtils.equals(imUserBean.getType(), model.getType())) {
imUserBean.setContent(model.getContent())
.setIsDelet(model.getIsDelet())
.setRemarks(model.getRemarks())
.setIs_admin(model.getIsAdmin())
.set_method_(model.getMethod())
.setAddtime(model.getAddtime())
.setImage(model.getImage())
.setLink(model.getLink())
.setNum(imUserBean.addNumber(1))
.setTitle(model.getTitle())
.setType(model.getType())
.setUserId(model.getUserId());
}
}
notifyDataSetChanged();
}
}

View File

@ -124,7 +124,7 @@ public class ConversationIMListManager {
CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
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 = "";

View File

@ -1,8 +1,6 @@
package com.yunbao.main.utils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@ -10,12 +8,10 @@ import java.util.List;
import io.rong.imkit.conversationlist.model.BaseUiConversation;
import io.rong.imkit.conversationlist.provider.BaseConversationProvider;
import io.rong.imkit.utils.RouteUtils;
import io.rong.imkit.widget.adapter.IViewProviderListener;
import io.rong.imkit.widget.adapter.ViewHolder;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.imlib.model.UserInfo;
/**
* pdlive自定义会话模板
@ -41,14 +37,17 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider {
//根据业务需要自定义处理
super.bindViewHolder(holder, uiConversation, position, list, listener);
if (list.size() > 0) {
Message.ReceivedStatus receivedStatus = list.get(position).mCore.getReceivedStatus();
ImageView readReceipt = holder.itemView.findViewById(com.yunbao.live.R.id.rc_read_receipt_new);
if (receivedStatus.isRead()) {
readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_message_unread);
readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_messagelist_read);
} else {
readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_message_read);
readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_messagelist_unread);
}
}
}
}

View File

@ -129,10 +129,10 @@
<TextView
android:id="@+id/v_table_redpoint"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:textColor="@color/white"
android:textSize="8dp"
android:textSize="10dp"
android:gravity="center"
android:background="@drawable/background_ff5075"
android:visibility="gone" />

View File

@ -107,12 +107,12 @@
<TextView
android:id="@+id/v_table_redpoint"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/background_ff5075"
android:gravity="center"
android:textColor="@color/white"
android:textSize="8dp"
android:textSize="10dp"
android:visibility="gone" />
</LinearLayout>

View File

@ -54,8 +54,8 @@
<TextView
android:id="@+id/red_point"
android:layout_width="20dp"
android:layout_height="15dp"
android:layout_width="23dp"
android:layout_height="20dp"
android:layout_below="@id/time"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
@ -67,7 +67,7 @@
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:textColor="#fff"
android:textSize="12sp"
android:textSize="8sp"
android:visibility="invisible" />