消息中心新增【系统消息】类型

This commit is contained in:
18401019693 2023-06-20 17:46:31 +08:00
parent a1c96cfd0f
commit 6889828c00
11 changed files with 288 additions and 97 deletions

View File

@ -30,7 +30,6 @@ public class SystemMessageActivity extends AbsActivity {
public static String type;//-1=单聊消息,1=系统消息,2=互动消息,3=猜你喜欢,-2=web页面打开
public static String type2 = "0";//判断是否注册监听
public static String nowUid, nowTitle, mowHeadImg;
// public static int mowMsgId;
public static void forward(Context context, String type, String uid, String title, String headImg) {
context.startActivity(new Intent(context, SystemMessageActivity.class)

View File

@ -0,0 +1,85 @@
package com.yunbao.live.adapter;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.live.R;
import com.yunbao.live.activity.ZhuangBanActivity;
import com.yunbao.live.bean.SystemMessageBean;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by cxf on 2018/11/24.
*/
public class SystemMessageNewAdapter extends RefreshAdapter<SystemMessageBean> {
public SystemMessageNewAdapter(Context context) {
super(context);
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new Vh(mInflater.inflate(R.layout.item_sys_msg_new, parent, false));
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
((Vh) vh).setData(mList.get(position));
}
class Vh extends RecyclerView.ViewHolder {
TextView messageContext, messageTime;
LinearLayout layoutMore;
public Vh(View itemView) {
super(itemView);
messageContext = itemView.findViewById(R.id.message_context);
layoutMore = itemView.findViewById(R.id.layout_more);
messageTime = itemView.findViewById(R.id.message_time);
}
void setData(SystemMessageBean bean) {
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
Date currenTimeZone = new Date(Long.parseLong(bean.getAddtime() + "000"));
messageTime.setText(sdf.format(currenTimeZone));
messageContext.setText(bean.getContent());
layoutMore.setVisibility(TextUtils.isEmpty(bean.getLink()) ? View.GONE : View.VISIBLE);
layoutMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (bean.getLink() != null && !bean.getLink().equals("")) {
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
StringBuffer urlBuffer = new StringBuffer();
urlBuffer.append(bean.getLink())
.append("&uid=")
.append(userInfo.getId())
.append("&token=")
.append(userInfo.getToken());
mContext.startActivity(
new Intent(mContext, ZhuangBanActivity.class)
.putExtra("url", urlBuffer.toString()));
}
}
});
}
}
}

View File

@ -1,5 +1,7 @@
package com.yunbao.live.views;
import static io.rong.imlib.RongIMClient.BlacklistStatus.NOT_IN_BLACK_LIST;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
@ -59,6 +61,7 @@ import com.yunbao.live.activity.EditNameRemarksActivity;
import com.yunbao.live.activity.SystemMessageActivity;
import com.yunbao.live.adapter.InteractionMessageAdapter;
import com.yunbao.live.adapter.SystemMessageAdapter;
import com.yunbao.live.adapter.SystemMessageNewAdapter;
import com.yunbao.live.adapter.YouLikeMessageAdapter;
import com.yunbao.live.bean.SearchUserBean;
import com.yunbao.live.bean.SystemMessageBean;
@ -89,8 +92,6 @@ import io.rong.message.RecallNotificationMessage;
import io.rong.message.SightMessage;
import io.rong.message.TextMessage;
import static io.rong.imlib.RongIMClient.BlacklistStatus.NOT_IN_BLACK_LIST;
/**
* Created by Chen Haoxuan on 2022/4/10.修改
*/
@ -339,67 +340,11 @@ public class SystemMessageViewHolder extends AbsViewHolder implements View.OnCli
}
});
// RongIMClient.getInstance().getRemoteHistoryMessages(conversationType, SystemMessageActivity.nowUid, dateTime, 20,
// new RongIMClient.ResultCallback<List<Message>>() {
// /**
// * 成功时回调
// * @param messages 获取的消息列表
// */
// @Override
// public void onSuccess(List<Message> messages) {
// if (messages.size() > 0) {
// if (messages.size() < 10) {
// moretext = false;
// } else {
// moretext = true;
// }
// dateTime = messages.get(messages.size() - 1).getSentTime();
// oldestMessageId = messages.get(messages.size() - 1).getMessageId();
// if (messagesList.size() == 0) {
// Message messageNo = new Message();
// messageNo.setSenderUserId("-1");
// messagesList.add(messageNo);
//
// messagesList.addAll(messages);
// } else {
// if (moretext) {
// messagesList.get(0).setSenderUserId("-1");
// } else {
// messagesList.get(0).setSenderUserId("-2");
// }
// messagesList.addAll(1, messages);
// }
// setData(messagesList.size());
// } else {
// moretext = false;
// if (messagesList.size() == 0) {
// Message messageNo = new Message();
// messageNo.setSenderUserId("-1");
// messagesList.add(messageNo);
//
// messagesList.addAll(messages);
// } else {
// messagesList.addAll(1, messages);
// }
// messagesList.get(0).setSenderUserId("-2");
// setData(messagesList.size());
// }
// }
//
// /**
// * 错误时回调
// * @param e 错误码
// */
// @Override
// public void onError(RongIMClient.ErrorCode e) {
// ToastUtil.show("消息获取失败");
// }
// });
}
//非单聊列表适配
private void setSysApt() {
if (SystemMessageActivity.type.equals("1")) {
if (SystemMessageActivity.type.equals("1") || SystemMessageActivity.type.equals("4")) {
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_sys);
} else if (SystemMessageActivity.type.equals("2")) {
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_mess);
@ -407,14 +352,16 @@ public class SystemMessageViewHolder extends AbsViewHolder implements View.OnCli
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_sys_msg);
}
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
if (SystemMessageActivity.type.equals("1") || SystemMessageActivity.type.equals("2")) {
if (SystemMessageActivity.type.equals("1") || SystemMessageActivity.type.equals("2") || SystemMessageActivity.type.equals("4")) {
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<SystemMessageBean>() {
@Override
public RefreshAdapter<SystemMessageBean> getAdapter() {
if (mAdapter == null && SystemMessageActivity.type.equals("1")) {
if (mAdapter == null && (SystemMessageActivity.type.equals("1"))) {
mAdapter = new SystemMessageAdapter(mContext);
} else if (mAdapter == null && SystemMessageActivity.type.equals("2")) {
mAdapter = new InteractionMessageAdapter(mContext, SystemMessageViewHolder.this);
} else if (mAdapter == null && SystemMessageActivity.type.equals("4")) {
mAdapter = new SystemMessageNewAdapter(mContext);
}
return mAdapter;
}

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/message_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="28dp"
android:layout_marginBottom="18dp"
android:gravity="center"
android:text="6月18日 13:25"
android:textColor="#7F7F7F"
android:textSize="11sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!--通知小喇叭-->
<ImageView
android:layout_width="37dp"
android:layout_height="37dp"
android:layout_marginStart="11dp"
android:src="@mipmap/icon_notification_speaker" />
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="42dp"
app:cardBackgroundColor="#fff"
app:cardCornerRadius="12dp"
app:cardElevation="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/message_context"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="11dp"
android:text="親愛的用戶昵稱恭喜你獲得23年7月1日-23年7月31日的xx禮物冠名權冠名生效期間您可使用專屬禮物冠名皮膚。小PD已給您佩戴了專屬送禮特效也可在個性裝扮中取消佩戴。"
android:textColor="#040404"
android:textSize="15sp" />
<LinearLayout
android:id="@+id/layout_more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1.2dp"
android:layout_marginStart="11dp"
android:layout_marginEnd="11dp"
android:background="#F6F6F6" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="11dp"
android:text="@string/live_user_mailbox_more_text"
android:textColor="#838383"
android:textSize="14sp" />
<ImageView
android:layout_width="13dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_marginEnd="11dp"
android:src="@mipmap/icon_arrow_right" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@ -15,6 +15,7 @@ import android.widget.TextView;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.alibaba.fastjson.JSON;
import com.binioter.guideview.Guide;
import com.binioter.guideview.GuideBuilder;
@ -37,7 +38,6 @@ import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.SVGAViewUtils;
import com.yunbao.common.views.AbsMainViewHolder;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.activity.SystemMessageActivity;
import com.yunbao.live.bean.ImUserBean;
import com.yunbao.live.event.RecommendLiveRoomEvent;
@ -67,11 +67,11 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
private ConversationListFragment conversationListFragment;
private FrameLayout container;
private SystemMessageAdapter messageAdapter;
private TextView textNewsNotice, textNewsInteraction, textNewsOnline;
private TextView textNewsNotice, textNewsInteraction, textNewsOnline, textSystemMessages;
private String type = null;
private List<ImUserBean> listUserBean = new ArrayList<>();
private LinearLayout topLayout, ltNodataMsg;
private ImageView imgNewsNotice, imgNewsInteraction, imgNewsOnline;
private ImageView imgNewsNotice, imgNewsInteraction, imgNewsOnline, imgSystemMessages;
private Handler netHandler;
private MainActivity mContext;
@ -110,10 +110,12 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
textNewsNotice = (TextView) findViewById(R.id.text_news_notice);
textNewsInteraction = (TextView) findViewById(R.id.text_news_interaction);
textNewsOnline = (TextView) findViewById(R.id.text_news_online);
textSystemMessages = (TextView) findViewById(R.id.text_system_messages);
topLayout = (LinearLayout) findViewById(R.id.top_layout);
ltNodataMsg = (LinearLayout) findViewById(R.id.lt_nodata_msg);
imgNewsNotice = (ImageView) findViewById(R.id.img_news_notice);
imgNewsInteraction = (ImageView) findViewById(R.id.img_news_interaction);
imgSystemMessages = (ImageView) findViewById(R.id.img_system_messages);
imgNewsOnline = (ImageView) findViewById(R.id.img_news_online);
netHandler = new Handler();
@ -285,6 +287,25 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
}
});
break;
//系统消息
case "4":
if (TextUtils.isEmpty(userBean.getNum()) || TextUtils.equals("0", userBean.getNum())) {
textSystemMessages.setVisibility(View.GONE);
} else {
textSystemMessages.setVisibility(View.VISIBLE);
textSystemMessages.setText(userBean.getNum());
}
ImgLoader.display(mContext, userBean.getNewImage(), imgSystemMessages);
ViewClicksAntiShake.clicksAntiShake(imgSystemMessages, () -> {
type = userBean.getType();
netHandler.post(systemNumberRunnable);
mContext.startActivity(new Intent(mContext, SystemMessageActivity.class)
.putExtra("type", userBean.getType())
.putExtra("uid", "")
.putExtra("title", userBean.getTitle())
.putExtra("headImg", ""));
});
break;
}
}
@ -327,6 +348,13 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
textNewsOnline.setVisibility(View.GONE);
}
break;
//在線客服
case "4":
if (TextUtils.equals(type, userBean.getType())) {
number = null;
textSystemMessages.setVisibility(View.GONE);
}
break;
}
//未读消息不为空并且大于0
@ -402,6 +430,17 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
textNewsOnline.setVisibility(View.VISIBLE);
textNewsOnline.setText(String.valueOf(numberInt));
}
break; //在線客服
case "4":
if (textSystemMessages.getVisibility() == View.GONE) {
textSystemMessages.setVisibility(View.GONE);
textSystemMessages.setText("");
} else {
String number = textSystemMessages.getText().toString().trim();
int numberInt = Integer.parseInt(number) + 1;
textSystemMessages.setVisibility(View.VISIBLE);
textSystemMessages.setText(String.valueOf(numberInt));
}
break;
}
systemNumber = systemNumber + 1;
@ -419,7 +458,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
}
@Override

View File

@ -2,8 +2,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="20dp"
android:orientation="vertical">
android:orientation="vertical"
android:paddingTop="20dp">
<FrameLayout
android:layout_width="match_parent"
@ -35,91 +35,117 @@
android:id="@+id/top_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--系统消息-->
<RelativeLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_height="110dp"
android:layout_weight="1">
<ImageView
android:id="@+id/img_news_notice"
android:layout_width="120dp"
android:layout_height="130dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="99dp"
android:layout_centerInParent="true"
android:src="@mipmap/img_news_notice" />
<TextView
android:id="@+id/text_news_notice"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="9dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="17dp"
android:background="@drawable/background_system_message"
android:gravity="center"
android:text="7"
android:textColor="@color/white"
android:textSize="12sp"
android:visibility="gone" />
android:visibility="visible" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="110dp"
android:layout_weight="1">
<ImageView
android:id="@+id/img_system_messages"
android:layout_width="match_parent"
android:layout_height="99dp"
android:layout_centerInParent="true"
android:src="@mipmap/img_system_messages" />
<TextView
android:id="@+id/text_system_messages"
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="15dp"
android:layout_marginEnd="17dp"
android:background="@drawable/background_system_message"
android:gravity="center"
android:text="7"
android:textColor="@color/white"
android:textSize="12sp"
android:visibility="visible" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_height="110dp"
android:layout_weight="1">
<ImageView
android:id="@+id/img_news_interaction"
android:layout_width="120dp"
android:layout_height="130dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="99dp"
android:layout_centerInParent="true"
android:src="@mipmap/img_news_interaction" />
<TextView
android:id="@+id/text_news_interaction"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="17dp"
android:background="@drawable/background_system_message"
android:gravity="center"
android:text="7"
android:textColor="@color/white"
android:textSize="12sp"
android:visibility="gone" />
android:visibility="visible" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_height="110dp"
android:layout_weight="1">
<ImageView
android:id="@+id/img_news_online"
android:layout_width="120dp"
android:layout_height="130dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="99dp"
android:layout_centerInParent="true"
android:src="@mipmap/img_news_online" />
<TextView
android:id="@+id/text_news_online"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="17dp"
android:background="@drawable/background_system_message"
android:gravity="center"
android:text="7"
android:textColor="@color/white"
android:textSize="12sp"
android:visibility="gone" />
android:visibility="visible" />
</RelativeLayout>
</LinearLayout>
<!-- 此容器用于动态放置 fragment-->

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB