feat:公聊厅消息列表支持头饰展示
This commit is contained in:
@@ -17,6 +17,7 @@ import androidx.core.util.Consumer;
|
|||||||
import com.chwl.app.public_chat.core.ChatRoomMessageAdapter;
|
import com.chwl.app.public_chat.core.ChatRoomMessageAdapter;
|
||||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||||
import com.chwl.app.ui.widget.TextSpannableBuilder;
|
import com.chwl.app.ui.widget.TextSpannableBuilder;
|
||||||
|
import com.chwl.core.decoration.headwear.bean.HeadWearInfo;
|
||||||
import com.chwl.core.level.UserLevelResourceType;
|
import com.chwl.core.level.UserLevelResourceType;
|
||||||
import com.chwl.core.noble.NobleUtil;
|
import com.chwl.core.noble.NobleUtil;
|
||||||
import com.chwl.core.user.bean.UserInfo;
|
import com.chwl.core.user.bean.UserInfo;
|
||||||
@@ -64,6 +65,10 @@ public abstract class ChatRoomMessageViewHolderBase extends RecyclerViewHolder<B
|
|||||||
protected View.OnLongClickListener longClickListener;
|
protected View.OnLongClickListener longClickListener;
|
||||||
private HeadImageView avatarLeft;
|
private HeadImageView avatarLeft;
|
||||||
private HeadImageView avatarRight;
|
private HeadImageView avatarRight;
|
||||||
|
private ImageView headWearLeft;
|
||||||
|
private ImageView headWearRight;
|
||||||
|
private View headWearLeftLayout;
|
||||||
|
private View headWearRightLayout;
|
||||||
private int expLevelHeight = UiUtils.INSTANCE.dip2px(18f);
|
private int expLevelHeight = UiUtils.INSTANCE.dip2px(18f);
|
||||||
|
|
||||||
public ChatRoomMessageViewHolderBase(BaseMultiItemFetchLoadAdapter adapter) {
|
public ChatRoomMessageViewHolderBase(BaseMultiItemFetchLoadAdapter adapter) {
|
||||||
@@ -185,6 +190,10 @@ public abstract class ChatRoomMessageViewHolderBase extends RecyclerViewHolder<B
|
|||||||
timeTextView = findViewById(R.id.message_item_time);
|
timeTextView = findViewById(R.id.message_item_time);
|
||||||
avatarLeft = findViewById(R.id.message_item_portrait_left);
|
avatarLeft = findViewById(R.id.message_item_portrait_left);
|
||||||
avatarRight = findViewById(R.id.message_item_portrait_right);
|
avatarRight = findViewById(R.id.message_item_portrait_right);
|
||||||
|
headWearLeftLayout = findViewById(R.id.message_item_portrait_left_layout);
|
||||||
|
headWearRightLayout = findViewById(R.id.message_item_portrait_right_layout);
|
||||||
|
headWearLeft = findViewById(R.id.message_item_head_wear_left);
|
||||||
|
headWearRight = findViewById(R.id.message_item_head_wear_right);
|
||||||
alertButton = findViewById(R.id.message_item_alert);
|
alertButton = findViewById(R.id.message_item_alert);
|
||||||
progressBar = findViewById(R.id.message_item_progress);
|
progressBar = findViewById(R.id.message_item_progress);
|
||||||
nameTextView = findViewById(R.id.message_item_nickname);
|
nameTextView = findViewById(R.id.message_item_nickname);
|
||||||
@@ -257,25 +266,48 @@ public abstract class ChatRoomMessageViewHolderBase extends RecyclerViewHolder<B
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setHeadImageView() {
|
private void setHeadImageView() {
|
||||||
HeadImageView show = isReceivedMessage() ? avatarLeft : avatarRight;
|
View showLayout = isReceivedMessage() ? headWearLeftLayout : headWearRightLayout;
|
||||||
HeadImageView hide = isReceivedMessage() ? avatarRight : avatarLeft;
|
View hideLayout = isReceivedMessage() ? headWearRightLayout : headWearLeftLayout;
|
||||||
hide.setVisibility(View.GONE);
|
HeadImageView showAvatarView = isReceivedMessage() ? avatarLeft : avatarRight;
|
||||||
|
ImageView showHeadWearView = isReceivedMessage() ? headWearLeft : headWearRight;
|
||||||
|
ImageView hideHeadWearView = isReceivedMessage() ? headWearRight : headWearLeft;
|
||||||
|
hideLayout.setVisibility(View.GONE);
|
||||||
|
clearHeadWear(hideHeadWearView);
|
||||||
if (!isShowHeadImage()) {
|
if (!isShowHeadImage()) {
|
||||||
show.setVisibility(View.GONE);
|
clearHeadWear(showHeadWearView);
|
||||||
|
showLayout.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isMiddleItem()) {
|
if (isMiddleItem()) {
|
||||||
show.setVisibility(View.GONE);
|
clearHeadWear(showHeadWearView);
|
||||||
|
showLayout.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
show.setVisibility(View.VISIBLE);
|
showLayout.setVisibility(View.VISIBLE);
|
||||||
String avatar = NobleUtil.getLevel(UserInfo.AVATAR, message);
|
String avatar = NobleUtil.getResource(UserInfo.AVATAR, message);
|
||||||
if (avatar.length() != 0) {
|
if (avatar.length() != 0) {
|
||||||
show.loadAvatar(avatar);
|
showAvatarView.loadAvatar(avatar);
|
||||||
} else {
|
} else {
|
||||||
show.loadBuddyAvatar(message);
|
showAvatarView.loadBuddyAvatar(message);
|
||||||
|
}
|
||||||
|
String headWear = NobleUtil.getResource(HeadWearInfo.HEAD_WEAR, message);
|
||||||
|
if (headWear.length() != 0) {
|
||||||
|
if (!headWear.equals(showHeadWearView.getTag(com.chwl.app.R.id.mic_item_head_wear))) {
|
||||||
|
showHeadWearView.setVisibility(View.VISIBLE);
|
||||||
|
showHeadWearView.setTag(com.chwl.app.R.id.mic_item_head_wear, headWear);
|
||||||
|
NobleUtil.loadMicHeadWear(headWear, showHeadWearView, com.chwl.app.R.id.mic_item_head_wear, headWear);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
clearHeadWear(showHeadWearView);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clearHeadWear(ImageView view) {
|
||||||
|
if (view == null) return;
|
||||||
|
view.clearAnimation();
|
||||||
|
view.setImageDrawable(null);
|
||||||
|
view.setTag(com.chwl.app.R.id.mic_item_head_wear, null);
|
||||||
|
view.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOnClickListener() {
|
private void setOnClickListener() {
|
||||||
|
@@ -275,7 +275,7 @@ public class PublicChatRoomMessageListPanel {
|
|||||||
if (needRefresh) {
|
if (needRefresh) {
|
||||||
sortMessages(items);
|
sortMessages(items);
|
||||||
if (items.size() > maxMessageCount) {
|
if (items.size() > maxMessageCount) {
|
||||||
for (int i = 0; i < maxMessageCount / 2; i++) {
|
for (int i = 0; i < maxMessageCount / 3; i++) {
|
||||||
items.remove(0);
|
items.remove(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ import lombok.Setter;
|
|||||||
public class HeadWearInfo extends BaseDecoration implements Serializable {
|
public class HeadWearInfo extends BaseDecoration implements Serializable {
|
||||||
public static final String PIC = "pic";
|
public static final String PIC = "pic";
|
||||||
public static final String EFFECT = "effect";
|
public static final String EFFECT = "effect";
|
||||||
|
public static final String HEAD_WEAR = "headWearUrl";
|
||||||
public static final int STATUS_IN_USED = 1;
|
public static final int STATUS_IN_USED = 1;
|
||||||
public static final int STATUS_OUT_OF_DATE = 2;
|
public static final int STATUS_OUT_OF_DATE = 2;
|
||||||
|
|
||||||
@@ -69,6 +70,11 @@ public class HeadWearInfo extends BaseDecoration implements Serializable {
|
|||||||
}
|
}
|
||||||
map.put(PIC, pic);
|
map.put(PIC, pic);
|
||||||
map.put(EFFECT, effect);
|
map.put(EFFECT, effect);
|
||||||
|
if (effect != null && effect.length() > 0) {
|
||||||
|
map.put(HEAD_WEAR, effect);
|
||||||
|
} else {
|
||||||
|
map.put(HEAD_WEAR, pic);
|
||||||
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,53 +1,88 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:clipChildren="false"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingTop="6dp"
|
|
||||||
android:paddingBottom="6dp"
|
|
||||||
android:paddingStart="15dp"
|
android:paddingStart="15dp"
|
||||||
android:paddingEnd="15dp">
|
android:paddingTop="6dp"
|
||||||
|
android:paddingEnd="15dp"
|
||||||
|
android:paddingBottom="6dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/message_item_time"
|
android:id="@+id/message_item_time"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginBottom="@dimen/bubble_time_layout_margin_bottom"
|
|
||||||
android:layout_marginTop="@dimen/bubble_time_layout_margin_top"
|
android:layout_marginTop="@dimen/bubble_time_layout_margin_top"
|
||||||
|
android:layout_marginBottom="@dimen/bubble_time_layout_margin_bottom"
|
||||||
android:paddingStart="7dip"
|
android:paddingStart="7dip"
|
||||||
android:paddingEnd="7dip"
|
android:paddingEnd="7dip"
|
||||||
android:textColor="#666666"
|
android:textColor="#666666"
|
||||||
android:textSize="11sp"
|
android:textSize="11sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<com.netease.nim.uikit.common.ui.imageview.HeadImageView
|
<FrameLayout
|
||||||
android:id="@+id/message_item_portrait_left"
|
android:id="@+id/message_item_portrait_left_layout"
|
||||||
android:layout_width="45dp"
|
android:layout_width="45dp"
|
||||||
android:layout_height="45dp"
|
android:layout_height="45dp"
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_below="@id/message_item_time"
|
android:layout_below="@id/message_item_time"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
android:clipChildren="false"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<com.netease.nim.uikit.common.ui.imageview.HeadImageView
|
||||||
|
android:id="@+id/message_item_portrait_left"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/message_item_head_wear_left"
|
||||||
|
android:layout_width="59.4dp"
|
||||||
|
android:layout_height="59.4dp"
|
||||||
|
android:layout_marginStart="-7.2dp"
|
||||||
|
android:layout_marginTop="-7.2dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/message_item_portrait_right_layout"
|
||||||
|
android:layout_width="45dp"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_below="@id/message_item_time"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<com.netease.nim.uikit.common.ui.imageview.HeadImageView
|
<com.netease.nim.uikit.common.ui.imageview.HeadImageView
|
||||||
android:id="@+id/message_item_portrait_right"
|
android:id="@+id/message_item_portrait_right"
|
||||||
android:layout_width="45dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="45dp"
|
android:layout_height="match_parent" />
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_below="@id/message_item_time"
|
<ImageView
|
||||||
android:layout_marginStart="8dp"
|
android:id="@+id/message_item_head_wear_right"
|
||||||
android:visibility="gone" />
|
android:layout_width="59.4dp"
|
||||||
|
android:layout_height="59.4dp"
|
||||||
|
android:layout_marginStart="-7.2dp"
|
||||||
|
android:layout_marginTop="-7.2dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:id="@+id/message_item_name_layout"
|
android:id="@+id/message_item_name_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/message_item_time"
|
android:layout_below="@id/message_item_time"
|
||||||
android:layout_toStartOf="@id/message_item_portrait_right"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_toEndOf="@id/message_item_portrait_left"
|
android:layout_toStartOf="@id/message_item_portrait_right_layout"
|
||||||
|
android:layout_toEndOf="@id/message_item_portrait_left_layout"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@@ -57,10 +92,10 @@
|
|||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_marginBottom="10dp"
|
|
||||||
android:id="@+id/message_item_nickname"
|
android:id="@+id/message_item_nickname"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:maxWidth="200dip"
|
android:maxWidth="200dip"
|
||||||
@@ -74,8 +109,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@id/message_item_name_layout"
|
android:layout_below="@id/message_item_name_layout"
|
||||||
android:layout_toStartOf="@id/message_item_portrait_right"
|
android:layout_toStartOf="@id/message_item_portrait_right_layout"
|
||||||
android:layout_toEndOf="@id/message_item_portrait_left">
|
android:layout_toEndOf="@id/message_item_portrait_left_layout">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/message_item_body"
|
android:id="@+id/message_item_body"
|
||||||
|
Reference in New Issue
Block a user