diff --git a/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java b/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java index 0d3b5ab39..461ae839d 100644 --- a/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java @@ -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) diff --git a/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java b/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java new file mode 100644 index 000000000..051383f9d --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java @@ -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 { + + 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())); + + } + } + }); + } + } + +} diff --git a/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java b/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java index bd0e195e1..182f7518c 100644 --- a/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java @@ -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>() { -// /** -// * 成功时回调 -// * @param messages 获取的消息列表 -// */ -// @Override -// public void onSuccess(List 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() { @Override public RefreshAdapter 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; } diff --git a/live/src/main/res/layout/item_sys_msg_new.xml b/live/src/main/res/layout/item_sys_msg_new.xml new file mode 100644 index 000000000..b266c26bc --- /dev/null +++ b/live/src/main/res/layout/item_sys_msg_new.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/live/src/main/res/mipmap-xxxhdpi/icon_notification_speaker.png b/live/src/main/res/mipmap-xxxhdpi/icon_notification_speaker.png new file mode 100644 index 000000000..57b5166d0 Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/icon_notification_speaker.png differ diff --git a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java index 26e38cdb7..1e29d3a83 100644 --- a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java @@ -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 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 diff --git a/main/src/main/res/layout/view_main_message.xml b/main/src/main/res/layout/view_main_message.xml index de0adb09b..d4dbdfe78 100644 --- a/main/src/main/res/layout/view_main_message.xml +++ b/main/src/main/res/layout/view_main_message.xml @@ -2,8 +2,8 @@ + android:orientation="vertical" + android:paddingTop="20dp"> - + + android:visibility="visible" /> + + + + + + + + + android:visibility="visible" /> + android:visibility="visible" /> diff --git a/main/src/main/res/mipmap-xxhdpi/img_news_interaction.png b/main/src/main/res/mipmap-xxhdpi/img_news_interaction.png index 96b9ebace..ef2ec3924 100644 Binary files a/main/src/main/res/mipmap-xxhdpi/img_news_interaction.png and b/main/src/main/res/mipmap-xxhdpi/img_news_interaction.png differ diff --git a/main/src/main/res/mipmap-xxhdpi/img_news_notice.png b/main/src/main/res/mipmap-xxhdpi/img_news_notice.png index 5934c8396..740ec51ba 100644 Binary files a/main/src/main/res/mipmap-xxhdpi/img_news_notice.png and b/main/src/main/res/mipmap-xxhdpi/img_news_notice.png differ diff --git a/main/src/main/res/mipmap-xxhdpi/img_news_online.png b/main/src/main/res/mipmap-xxhdpi/img_news_online.png index 5628eaa96..c3ed8bfe5 100644 Binary files a/main/src/main/res/mipmap-xxhdpi/img_news_online.png and b/main/src/main/res/mipmap-xxhdpi/img_news_online.png differ diff --git a/main/src/main/res/mipmap-xxhdpi/img_system_messages.png b/main/src/main/res/mipmap-xxhdpi/img_system_messages.png new file mode 100644 index 000000000..175ff2f8b Binary files /dev/null and b/main/src/main/res/mipmap-xxhdpi/img_system_messages.png differ