dian9图问题直播间聊天列表优化

This commit is contained in:
18401019693 2022-10-11 17:26:49 +08:00
parent 7e35cc8e3c
commit 447f8537f1
11 changed files with 162 additions and 7 deletions

View File

@ -166,6 +166,7 @@ public class Constants {
public static final String SOCKET_HOUR = "SendHourChart";//小时榜更新 public static final String SOCKET_HOUR = "SendHourChart";//小时榜更新
public static final String RECOMMEND_CARD_NOTIFY = "recommendCardNotify";//推荐卡通知消息 public static final String RECOMMEND_CARD_NOTIFY = "recommendCardNotify";//推荐卡通知消息
public static final String STAR_CHALLENGE_UPDATE = "starChallengeUpdate";//星级助力 public static final String STAR_CHALLENGE_UPDATE = "starChallengeUpdate";//星级助力
public static final String AI_AUTOMATIC_SPEECH = "aiAutomaticSpeech";//机器人助手
//游戏socket //游戏socket
public static final String SOCKET_GAME_ZJH = "startGame";//炸金花 public static final String SOCKET_GAME_ZJH = "startGame";//炸金花

View File

@ -0,0 +1,81 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
/**
* 机器人助手IM消息
*/
public class AiAutomaticSpeechModel extends BaseModel {
//助手名字颜色
@SerializedName("name_color")
private String nameColor;
//助手名字
@SerializedName("ai_name")
private String aiName;
//说话内容
@SerializedName("content")
private String content;
//@用户名字
@SerializedName("user_name")
private String userName;
//标签图片
@SerializedName("icon")
private String icon;
//气泡背景
@SerializedName("system_bubble")
private String systemBubble;
public String getNameColor() {
return nameColor;
}
public AiAutomaticSpeechModel setNameColor(String nameColor) {
this.nameColor = nameColor;
return this;
}
public String getAiName() {
return aiName;
}
public AiAutomaticSpeechModel setAiName(String aiName) {
this.aiName = aiName;
return this;
}
public String getContent() {
return content;
}
public AiAutomaticSpeechModel setContent(String content) {
this.content = content;
return this;
}
public String getUserName() {
return userName;
}
public AiAutomaticSpeechModel setUserName(String userName) {
this.userName = userName;
return this;
}
public String getIcon() {
return icon;
}
public AiAutomaticSpeechModel setIcon(String icon) {
this.icon = icon;
return this;
}
public String getSystemBubble() {
return systemBubble;
}
public AiAutomaticSpeechModel setSystemBubble(String systemBubble) {
this.systemBubble = systemBubble;
return this;
}
}

View File

@ -846,6 +846,9 @@ public class LiveAudienceActivity extends LiveActivity {
case START_MESSAGE: case START_MESSAGE:
manager.starMessage(event.getMsgModel()); manager.starMessage(event.getMsgModel());
break; break;
case AI_AUTOMATIC_SPEECH:
manager.aiAutomaticSpeech(event.getAiAutomaticSpeechModel());
break;
} }

View File

@ -1,5 +1,6 @@
package com.yunbao.live.adapter; package com.yunbao.live.adapter;
import static com.yunbao.live.bean.LiveChatBean.AI_AUTOMATIC_SPEECH;
import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
@ -331,6 +332,9 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
//加载.9图聊天气泡 //加载.9图聊天气泡
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1); LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
LiveTextRender.recommendCardNotify(mContext, mTextView, bean); LiveTextRender.recommendCardNotify(mContext, mTextView, bean);
} else if (bean.getType() == AI_AUTOMATIC_SPEECH) {
//加载.9图聊天气泡
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getAiAutomaticSpeechModel().getSystemBubble(), 1);
} else { } else {
if (bean.getBubble() != null && !bean.getBubble().equals("")) { if (bean.getBubble() != null && !bean.getBubble().equals("")) {
//加载.9图聊天气泡 //加载.9图聊天气泡

View File

@ -2,6 +2,7 @@ package com.yunbao.live.bean;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import com.yunbao.common.bean.AiAutomaticSpeechModel;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
/** /**
@ -17,6 +18,7 @@ public class LiveChatBean {
public static final int LIGHT = 4; public static final int LIGHT = 4;
public static final int RED_PACK = 5; public static final int RED_PACK = 5;
public static final int RECOMMEND_CARD_NOTIFY = 10; public static final int RECOMMEND_CARD_NOTIFY = 10;
public static final int AI_AUTOMATIC_SPEECH = 101;
private String id; private String id;
private String userNiceName; private String userNiceName;
@ -41,6 +43,17 @@ public class LiveChatBean {
private String prankIcon; private String prankIcon;
private String hot_card; private String hot_card;
private MsgModel msgModel = new MsgModel();//自定义消息体 private MsgModel msgModel = new MsgModel();//自定义消息体
private AiAutomaticSpeechModel aiAutomaticSpeechModel = new AiAutomaticSpeechModel();//机器人消息体
public AiAutomaticSpeechModel getAiAutomaticSpeechModel() {
return aiAutomaticSpeechModel;
}
public LiveChatBean setAiAutomaticSpeechModel(AiAutomaticSpeechModel aiAutomaticSpeechModel) {
this.aiAutomaticSpeechModel = aiAutomaticSpeechModel;
return this;
}
@SerializedName("noble_id") @SerializedName("noble_id")
private String nobleId = ""; private String nobleId = "";

View File

@ -1,6 +1,7 @@
package com.yunbao.live.event; package com.yunbao.live.event;
import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.ActiveModel;
import com.yunbao.common.bean.AiAutomaticSpeechModel;
import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.AnchorRecommendItemModel;
import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
@ -18,6 +19,16 @@ public class LiveAudienceEvent extends BaseModel {
private int liveType; private int liveType;
private int liveTypeVal; private int liveTypeVal;
private MsgModel msgModel;//全服消息 private MsgModel msgModel;//全服消息
private AiAutomaticSpeechModel aiAutomaticSpeechModel;//机器人消息
public AiAutomaticSpeechModel getAiAutomaticSpeechModel() {
return aiAutomaticSpeechModel;
}
public LiveAudienceEvent setAiAutomaticSpeechModel(AiAutomaticSpeechModel aiAutomaticSpeechModel) {
this.aiAutomaticSpeechModel = aiAutomaticSpeechModel;
return this;
}
public MsgModel getMsgModel() { public MsgModel getMsgModel() {
return msgModel; return msgModel;
@ -134,7 +145,9 @@ public class LiveAudienceEvent extends BaseModel {
SLIDE_SETTINGS(22, "滑動設置"), SLIDE_SETTINGS(22, "滑動設置"),
NEW_MESSAGE_REMINDER(23, "新消息提醒"), NEW_MESSAGE_REMINDER(23, "新消息提醒"),
AT_MESSAGE(24, "@消息"), AT_MESSAGE(24, "@消息"),
START_MESSAGE(25, "星级消息"); START_MESSAGE(25, "星级消息"),
AI_AUTOMATIC_SPEECH(26, "机器人助手"),
;
private int type; private int type;
private String name; private String name;

View File

@ -21,6 +21,7 @@ import com.blankj.utilcode.util.GsonUtils;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.bean.AiAutomaticSpeechModel;
import com.yunbao.common.bean.FansMedalBean; import com.yunbao.common.bean.FansMedalBean;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.SocketModel; import com.yunbao.common.bean.SocketModel;
@ -480,6 +481,13 @@ public class SocketRyClient {
.setMsgModel(starChallengeMsg.get(0))); .setMsgModel(starChallengeMsg.get(0)));
} }
break; break;
case Constants.AI_AUTOMATIC_SPEECH:
//{"name_color":"#f19ec2","ai_name":"助手小小P","content":"@1 ","user_name":"1","icon":"https://downs.yaoulive.com/xzs_tab.png","system_bubble":"https://downs.yaoulive.com/xzs_qipao.9.png"}
AiAutomaticSpeechModel aiAutomaticSpeechModel = GsonUtils.fromJson(map.getString("ct"), AiAutomaticSpeechModel.class);
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.AI_AUTOMATIC_SPEECH)
.setAiAutomaticSpeechModel(aiAutomaticSpeechModel));
break;
} }
} }

View File

@ -254,7 +254,7 @@ public class LiveTextRender {
} }
public static void gz(final Context context, final TextView textView, final LiveChatBean bean) { public static void gz(final Context context, final TextView textView, final LiveChatBean bean) {
ImgLoader.displayDrawable(context, bean.getMedal_new(), new ImgLoader.DrawableCallback() { ImgLoader.displayDrawable(context, TextUtils.isEmpty(bean.getMedal_new())?bean.getMedal():bean.getMedal_new(), new ImgLoader.DrawableCallback() {
@Override @Override
public void onLoadSuccess(Drawable drawable) { public void onLoadSuccess(Drawable drawable) {
gzDrawables = null; gzDrawables = null;

View File

@ -33,13 +33,15 @@ public class LoadDian9TuUtil {
} }
} }
Glide.with(context) Glide.with(context)
.asBitmap() .asFile()
.load(imgUrl) .load(imgUrl)
.into(new CustomTarget<Bitmap>() { .into(new CustomTarget<File>() {
@Override @Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {
try { try {
setNinePathImage(context, imageView, resource, position); FileInputStream is = new FileInputStream(resource);
setNinePathImage(context, imageView, BitmapFactory.decodeStream(is), position);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -60,6 +60,7 @@ import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.bean.AiAutomaticSpeechModel;
import com.yunbao.common.bean.BannerBean; import com.yunbao.common.bean.BannerBean;
import com.yunbao.common.bean.HourRank; import com.yunbao.common.bean.HourRank;
import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
@ -815,7 +816,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mChatRecyclerView.setLayoutParams(params1); mChatRecyclerView.setLayoutParams(params1);
mChatRecyclerView.setHasFixedSize(true); mChatRecyclerView.setHasFixedSize(true);
mChatRecyclerView.setLayoutManager(new LinearLayoutManager(mContext)); LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
layoutManager.setStackFromEnd(true);
mChatRecyclerView.setLayoutManager(layoutManager);
mChatRecyclerView.addItemDecoration(new TopGradual()); mChatRecyclerView.addItemDecoration(new TopGradual());
mLiveChatAdapter = new LiveChatAdapter(mContext); mLiveChatAdapter = new LiveChatAdapter(mContext);
mLiveChatAdapter.setOnItemClickListener(new OnItemClickListener<LiveChatBean>() { mLiveChatAdapter.setOnItemClickListener(new OnItemClickListener<LiveChatBean>() {
@ -3251,4 +3254,19 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}, 100); }, 100);
} }
/**
* 机器人消息
*
* @param model
*/
public void aiAutomaticSpeech(AiAutomaticSpeechModel model) {
if (mLiveChatAdapter != null){
LiveChatBean bean = new LiveChatBean();
bean.setType(LiveChatBean.AI_AUTOMATIC_SPEECH);
bean.setAiAutomaticSpeechModel(model);
mLiveChatAdapter.insertItem(bean);
}
}
} }

View File

@ -36,6 +36,7 @@ import com.tencent.imsdk.v2.V2TIMManager;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.bean.AiAutomaticSpeechModel;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
@ -1579,4 +1580,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
.setCurrentAssistNum(msgModel.getCurrentAssistNum())); .setCurrentAssistNum(msgModel.getCurrentAssistNum()));
} }
} }
/**
* 机器人消息
*
* @param model
*/
public void aiAutomaticSpeech(AiAutomaticSpeechModel model) {
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.aiAutomaticSpeech(model);
}
}
} }