房间相册 公屏消息UI

This commit is contained in:
wzq
2023-10-17 14:08:23 +08:00
parent 623a721e58
commit 8f9a5bd565
8 changed files with 182 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ package com.yizhuan.erban.avroom.widget;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_ALBUM;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L1;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L2;
@@ -42,6 +43,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -59,6 +61,7 @@ import com.netease.nim.uikit.common.util.sys.ScreenUtil;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessageExtension;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
import com.netease.nimlib.sdk.msg.constant.NotificationType;
import com.netease.nimlib.sdk.msg.model.IMMessage;
@@ -735,8 +738,28 @@ public class MessageView extends FrameLayout {
this.data = data;
}
@Override
public int getItemViewType(int position) {
ChatRoomMessage chatRoomMessage = data.get(position);
if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) {
MsgAttachment attachment = chatRoomMessage.getAttachment();
if (attachment instanceof CustomAttachment) {
if (((CustomAttachment) attachment).getFirst() == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM) {
return CustomAttachment.CUSTOM_MSG_ROOM_ALBUM;
}
}
}
return super.getItemViewType(position);
}
@Override
public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM) {
return new MessageViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.layout_msg_view_holder_room_album, parent, false));
}
return new MessageViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_item_chatrrom_msg, parent, false));
}
@@ -995,6 +1018,8 @@ public class MessageView extends FrameLayout {
setGiftCompoundMsg(chatRoomMessage, tvContent);
} else if (first == CUSTOM_MSG_FAIRY) {
setFairyMsg(chatRoomMessage, tvContent);
} else if (first == CUSTOM_MSG_ROOM_ALBUM) {
setRoomAlbumMsg(chatRoomMessage, baseViewHolder);
} else {
tvContent.setTextColor(Color.WHITE);
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
@@ -1008,6 +1033,12 @@ public class MessageView extends FrameLayout {
}
}
private void setRoomAlbumMsg(ChatRoomMessage chatRoomMessage, MessageViewHolder baseViewHolder) {
ImageView ivUserLevel = baseViewHolder.itemView.findViewById(R.id.iv_user_level);
ImageView ivUserCharm = baseViewHolder.itemView.findViewById(R.id.iv_user_charm);
}
private void setFairyMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
if (chatRoomMessage.getAttachment() instanceof FairyMsgAttachment) {
FairyMsgAttachment attachment = (FairyMsgAttachment) chatRoomMessage.getAttachment();

View File

@@ -22,13 +22,13 @@ import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderAudioParty;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderChatHint;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderContent;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderP2PContactRecharge;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderFairy;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderGift;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderHello;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderLevel;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderLottery;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderOnline;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderP2PContactRecharge;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderRedPackage;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderRedPacket;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderSkill;
@@ -44,7 +44,6 @@ import com.yizhuan.xchat_android_core.im.custom.bean.CarAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.CarveUpGoldThirdLevelAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.ChatHintAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.CpInviteAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.P2PContactRechargeAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.FairySendAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingFamilyAttachment;
@@ -60,6 +59,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.NoticeAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.OpenRoomNotiAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.OpenSignInAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.P2PContactRechargeAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RedPacketAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.SkillMsgAttachment;

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/color_9168FA" />
<corners android:radius="@dimen/dp_6" />
</shape>

View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/dp_162"
android:layout_height="wrap_content"
android:background="@drawable/shape_room_message_bg"
android:padding="@dimen/dp_12">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_user_level"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_18"
android:adjustViewBounds="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@mipmap/ic_user_level" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_user_charm"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_18"
android:layout_marginStart="@dimen/dp_2"
android:adjustViewBounds="true"
android:visibility="visible"
app:layout_constraintStart_toEndOf="@id/iv_user_level"
app:layout_constraintTop_toTopOf="@id/iv_user_level"
tools:src="@drawable/ic_user_charm_level" />
<TextView
android:id="@+id/tv_nick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white_transparent_60"
android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="@id/iv_user_level"
app:layout_constraintStart_toEndOf="@id/iv_user_charm"
app:layout_constraintTop_toTopOf="@id/iv_user_level"
tools:text="nick" />
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/iv_photo"
android:layout_width="@dimen/dp_140"
android:layout_height="@dimen/dp_140"
android:layout_marginTop="@dimen/dp_4"
android:src="@drawable/default_cover"
app:layout_constraintStart_toStartOf="@id/iv_user_level"
app:layout_constraintTop_toBottomOf="@id/iv_user_level"
app:riv_corner_radius="@dimen/dp_8" />
<View
android:id="@+id/v_bottom_mask"
android:layout_width="0dp"
android:layout_height="@dimen/dp_28"
android:background="@drawable/bg_mask_room_album"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/iv_photo"
app:layout_constraintStart_toStartOf="@id/iv_photo" />
<ImageView
android:id="@+id/iv_gift"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_marginStart="@dimen/dp_6"
android:src="@drawable/default_cover"
app:layout_constraintBottom_toBottomOf="@id/v_bottom_mask"
app:layout_constraintStart_toStartOf="@id/v_bottom_mask"
app:layout_constraintTop_toTopOf="@id/v_bottom_mask" />
<ImageView
android:id="@+id/iv_diamond"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_marginStart="@dimen/dp_2"
android:src="@mipmap/ic_charge_diamond"
app:layout_constraintBottom_toBottomOf="@id/v_bottom_mask"
app:layout_constraintStart_toEndOf="@id/iv_gift"
app:layout_constraintTop_toTopOf="@id/v_bottom_mask" />
<TextView
android:id="@+id/tv_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/zero"
android:textColor="@color/white"
android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="@id/v_bottom_mask"
app:layout_constraintStart_toEndOf="@id/iv_diamond"
app:layout_constraintTop_toTopOf="@id/v_bottom_mask" />
<TextView
android:id="@+id/tv_unlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_2"
android:background="@drawable/bg_9168fa_6"
android:paddingStart="@dimen/dp_11"
android:paddingTop="@dimen/dp_3"
android:paddingEnd="@dimen/dp_11"
android:paddingBottom="@dimen/dp_3"
android:text="@string/unlock_mic"
android:textColor="@color/white"
android:textSize="@dimen/sp_11"
app:layout_constraintBottom_toBottomOf="@id/v_bottom_mask"
app:layout_constraintEnd_toEndOf="@id/v_bottom_mask"
app:layout_constraintTop_toTopOf="@id/v_bottom_mask" />
<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -97,7 +97,6 @@ import com.yizhuan.xchat_android_core.im.custom.bean.MonsterAttackAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.MonsterHuntingResultAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.MonsterStatusAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.MultiGiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.MultiLuckyGiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFreeGiftAttachment;

View File

@@ -100,7 +100,6 @@ import com.yizhuan.xchat_android_core.community.attachment.DynamicSysAttachment;
import com.yizhuan.xchat_android_core.community.attachment.UnReadCountAttachment;
import com.yizhuan.xchat_android_core.community.im.WorldDynamicAttachment;
import com.yizhuan.xchat_android_core.gift.GiftModel;
import com.yizhuan.xchat_android_core.gift.event.UpdateKnapFreeGiftNumEvent;
import com.yizhuan.xchat_android_core.im.custom.AttachManager;
import com.yizhuan.xchat_android_core.mentoring_relationship.attachment.MentoringApprenticeMissionFourAttachment;
import com.yizhuan.xchat_android_core.mentoring_relationship.attachment.MentoringApprenticeMissionOneAttachment;
@@ -127,8 +126,6 @@ import com.yizhuan.xchat_android_core.utils.LogUtils;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.yizhuan.xchat_android_library.utils.log.MLog;
import org.greenrobot.eventbus.EventBus;
/**
* 云信自定义消息解析器
*
@@ -651,6 +648,11 @@ public class CustomAttachParser implements MsgAttachmentParser {
attachment = new P2PContactRechargeAttachment();
}
break;
case CustomAttachment.CUSTOM_MSG_ROOM_ALBUM:
if (second == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM_SUB) {
attachment = new RoomAlbumAttachment();
}
break;
default:
LogUtils.e(ResUtil.getString(R.string.custom_bean_customattachparser_01) + first + " second=" + second);
break;

View File

@@ -475,6 +475,10 @@ public class CustomAttachment implements MsgAttachment {
*/
public static final int CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE = 1102;
public static final int CUSTOM_MSG_ROOM_ALBUM = 101;
public static final int CUSTOM_MSG_ROOM_ALBUM_SUB = 1011;
/**
* 自定义消息附件的类型,根据该字段区分不同的自定义消息
*/

View File

@@ -0,0 +1,15 @@
package com.yizhuan.xchat_android_core.im.custom.bean;
import com.alibaba.fastjson.JSONObject;
public class RoomAlbumAttachment extends CustomAttachment {
public RoomAlbumAttachment() {
super(CUSTOM_MSG_ROOM_ALBUM, CUSTOM_MSG_ROOM_ALBUM_SUB);
}
@Override
protected void parseData(JSONObject data) {
}
}