From c83db0ec77f53e04d1525230557fdf6e195620fc Mon Sep 17 00:00:00 2001
From: zlzw <583819556@qq.com>
Date: Wed, 26 Oct 2022 11:33:32 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B9=B8=E8=BF=90=E5=A5=B3?=
=?UTF-8?q?=E7=A5=9E=E9=80=9A=E7=9F=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/yunbao/common/Constants.java | 1 +
.../java/com/yunbao/common/bean/MsgModel.java | 24 ++++++++++++++
common/src/main/res/values/strings.xml | 1 +
.../live/activity/LiveAudienceActivity.java | 4 +++
.../yunbao/live/adapter/LiveChatAdapter.java | 9 +++++-
.../com/yunbao/live/bean/LiveChatBean.java | 1 +
.../yunbao/live/event/LiveAudienceEvent.java | 3 +-
.../yunbao/live/socket/SocketRyClient.java | 8 +++--
.../com/yunbao/live/utils/LiveTextRender.java | 32 +++++++++++++++----
.../yunbao/live/views/LiveRoomViewHolder.java | 18 ++++++++---
.../live/views/PortraitLiveManager.java | 9 ++++++
11 files changed, 94 insertions(+), 16 deletions(-)
diff --git a/common/src/main/java/com/yunbao/common/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java
index ff502b444..07f931213 100644
--- a/common/src/main/java/com/yunbao/common/Constants.java
+++ b/common/src/main/java/com/yunbao/common/Constants.java
@@ -181,6 +181,7 @@ public class Constants {
public static final String SOCKET_USEHOTCARD = "UseHotCard";//热度卡消息
public static final String LOVE_CHECK = "LoveCheck";//热度卡消息
public static final String TRUMPET_NOTIFY = "TrumpetNotify";//全栈喇叭
+ public static final String LuckyAngel = "LuckyCheck";//幸运天使
public static final int SOCKET_WHAT_CONN = 0;
public static final int SOCKET_WHAT_DISCONN = 2;
diff --git a/common/src/main/java/com/yunbao/common/bean/MsgModel.java b/common/src/main/java/com/yunbao/common/bean/MsgModel.java
index 7fc1f3d87..f75a7ceda 100644
--- a/common/src/main/java/com/yunbao/common/bean/MsgModel.java
+++ b/common/src/main/java/com/yunbao/common/bean/MsgModel.java
@@ -323,4 +323,28 @@ public class MsgModel extends BaseModel {
public void setLiveUid(String liveUid) {
this.liveUid = liveUid;
}
+
+ /**
+ * 幸运天使
+ */
+ @SerializedName("gift_name")
+ private String giftName;
+ @SerializedName("system_bubble")
+ private String system_bubble;
+
+ public String getGiftName() {
+ return giftName;
+ }
+
+ public void setGiftName(String giftName) {
+ this.giftName = giftName;
+ }
+
+ public String getSystem_bubble() {
+ return system_bubble;
+ }
+
+ public void setSystem_bubble(String system_bubble) {
+ this.system_bubble = system_bubble;
+ }
}
diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml
index f3f0ccd21..4611bf3b9 100644
--- a/common/src/main/res/values/strings.xml
+++ b/common/src/main/res/values/strings.xml
@@ -946,4 +946,5 @@
換一批
聊聊天
想在其他APP上方也顯示小窗,\n可前往設置進行授權。
+ 恭喜 %s 在幸運天使中抽中 %s!下一個幸運天使就是你哦!
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
index 8270ed01a..c62187ddf 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
@@ -683,6 +683,7 @@ public class LiveAudienceActivity extends LiveActivity {
@Subscribe(threadMode = ThreadMode.MAIN)
public void onOpenDrawer(LiveAudienceEvent event) {
Bundle bundle = new Bundle();
+ Log.i("SocketRyClient", "onOpenDrawer: "+event.getType()+" "+event);
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
switch (event.getType()) {
case SIDEBAR:
@@ -923,6 +924,9 @@ public class LiveAudienceActivity extends LiveActivity {
}
break;
+ case LUCKY_ANGEL:
+ manager.luckyAngel(event.getMsgModel());
+ break;
}
diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
index dc6f694ff..2933ee5b7 100644
--- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
+++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
@@ -1,6 +1,7 @@
package com.yunbao.live.adapter;
import static com.yunbao.live.bean.LiveChatBean.AI_AUTOMATIC_SPEECH;
+import static com.yunbao.live.bean.LiveChatBean.LUCKY_ANGEL;
import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY;
import static com.yunbao.live.bean.LiveChatBean.STAR_CHALLENGE_UPGRADE_NOTIFY;
@@ -343,7 +344,13 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystemBubble(), 1);
LiveTextRender.starChallengeUpgradeNotify(mContext, mTextView, bean.getMsgModel());
}
- } else {
+ } else if(bean.getType()==LUCKY_ANGEL){
+ if(!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())){
+ LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystem_bubble(), 1);
+ LiveTextRender.luckyAngel(mContext, mTextView, bean.getMsgModel());
+ }
+
+ } else{
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
//加载.9图聊天气泡
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
diff --git a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java
index bc745ae80..6165349f5 100644
--- a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java
+++ b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java
@@ -20,6 +20,7 @@ public class LiveChatBean {
public static final int RECOMMEND_CARD_NOTIFY = 10;
public static final int AI_AUTOMATIC_SPEECH = 101;
public static final int STAR_CHALLENGE_UPGRADE_NOTIFY = 105;
+ public static final int LUCKY_ANGEL = 106;//幸运天使
private String id;
private String userNiceName;
diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
index b4e43512d..794885025 100644
--- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
+++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
@@ -160,7 +160,8 @@ public class LiveAudienceEvent extends BaseModel {
STAR_CHALLENGE_UPGRADE_NOTIFY(27, "星级挑战成功"),
MESSAGE_BOTTOM(28, "聊天消息滚动到底部"),
FLOAT_SETTING(29, "悬浮窗设置"),
- VOICE_PRESS(30, "长按展示图片");
+ VOICE_PRESS(30, "长按展示图片"),
+ LUCKY_ANGEL(31,"幸运天使");
private int type;
private String name;
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
index c0252f72d..ea1fae852 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
@@ -133,7 +133,7 @@ public class SocketRyClient {
public void processBroadcast(String socketMsg) {
L.e("收到socket--->" + socketMsg);
- Log.i("tag", "socketMsg" + socketMsg);
+ Log.i("SocketRyClient", "socketMsg" + socketMsg);
if (Constants.SOCKET_STOP_PLAY.equals(socketMsg)) {
mListener.onSuperCloseLive();//超管关闭房间
@@ -143,7 +143,6 @@ public class SocketRyClient {
return;
}
SocketReceiveBean received = JSON.parseObject(socketMsg, SocketReceiveBean.class);
- Log.i("tag", "1" + "礼物");
JSONObject map = received.getMsg().getJSONObject(0);
@@ -498,6 +497,11 @@ public class SocketRyClient {
.setMsgModel(starChallengeUpgradeNotifyMsg.get(0)));
}
break;
+ case Constants.LuckyAngel:
+ Bus.get().post(new LiveAudienceEvent()
+ .setType(LiveAudienceEvent.LiveAudienceType.LUCKY_ANGEL)
+ .setMsgModel( GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
+ break;
}
}
diff --git a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
index 539a66a1a..eb360679d 100644
--- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
+++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
@@ -52,10 +52,10 @@ public class LiveTextRender {
private static AbsoluteSizeSpan sFontSizeSpan;
private static AbsoluteSizeSpan sFontSizeSpan2;
private static AbsoluteSizeSpan sFontSizeSpan3;
- private static final Map mDrawableMedalMap=new HashMap<>();
- private static final Map gzDrawablesMap=new HashMap<>();
- private static final Map ryxzDrawablesMap=new HashMap<>();
- private static final Map nhDrawablesMap=new HashMap<>();
+ private static final Map mDrawableMedalMap = new HashMap<>();
+ private static final Map gzDrawablesMap = new HashMap<>();
+ private static final Map ryxzDrawablesMap = new HashMap<>();
+ private static final Map nhDrawablesMap = new HashMap<>();
static {
sBoldSpan = new StyleSpan(Typeface.BOLD);
@@ -123,6 +123,23 @@ public class LiveTextRender {
}
+ /**
+ * 幸运天使
+ */
+ public static void luckyAngel(Context mContext, TextView mTextView, MsgModel msgModel) {
+ String msg = mContext.getString(R.string.lucky_angel);
+ msg = String.format(msg, msgModel.getUserName(), msgModel.getGiftName());
+ int unameIndexOf = msg.indexOf(msgModel.getUserName());
+ int giftIndexOf = msg.indexOf(msgModel.getGiftName());
+ int unameSize = msgModel.getUserName().length();
+ int giftSize = msgModel.getGiftName().length();
+ SpannableStringBuilder builder = new SpannableStringBuilder();
+ builder.append(msg);
+ builder.setSpan(new ForegroundColorSpan(Color.parseColor("#78FEFF")), unameIndexOf, unameIndexOf + unameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFF86C")), giftIndexOf, giftIndexOf + giftSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ mTextView.setText(builder);
+ }
+
public static void aiAutomaticSpeech(Context activity, TextView textView, AiAutomaticSpeechModel model) {
ImgLoader.displayDrawable(activity, model.getIcon(), new ImgLoader.DrawableCallback() {
@Override
@@ -324,7 +341,7 @@ public class LiveTextRender {
ImgLoader.displayDrawable(context, bean.getMedal_honor(), new ImgLoader.DrawableCallback() {
@Override
public void onLoadSuccess(Drawable drawable) {
- ryxzDrawablesMap.put(bean,drawable);
+ ryxzDrawablesMap.put(bean, drawable);
nh(context, textView, bean);
}
@@ -337,7 +354,7 @@ public class LiveTextRender {
public static void nh(final Context context, final TextView textView, final LiveChatBean bean) {
if (bean.getGood_nub() != null && !bean.getGood_nub().equals("")) {
- nhDrawablesMap.put(bean,ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.good_nub));
+ nhDrawablesMap.put(bean, ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.good_nub));
renderTMP(context, textView, bean);
} else {
renderTMP(context, textView, bean);
@@ -604,7 +621,8 @@ public class LiveTextRender {
builder.setSpan(sFontSizeSpan2, index1, index2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return builder;
}
- public static void clear(){
+
+ public static void clear() {
mDrawableMedalMap.clear();
gzDrawablesMap.clear();
ryxzDrawablesMap.clear();
diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
index d0ea44ba0..09ad520cd 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
@@ -721,11 +721,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (!IMLoginManager.get(mContext).hintChat()) {
msgLayout.setVisibility(View.VISIBLE);
}
- //msgLayout.removeAllViews();
- /*msgLayout.setOnClickListener(v -> {
- LiveEnterRoomBean bean = JSON.parseObject("{\"liveChatBean\":{\"aiAutomaticSpeechModel\":{\"aiName\":\"null:\"},\"anchor\":false,\"atUserID\":\"\",\"atUserName\":\"\",\"bubble\":\"\",\"content\":\"駕馭着公爵專屬座駕【神化龍魚】霸氣進場了\",\"contentColor\":\"\",\"endColor\":\"\",\"guard_type\":0,\"heart\":0,\"hot_num\":\"75974\",\"id\":\"158329\",\"level\":58,\"manager\":false,\"medal_name\":\"\",\"medal_new\":\"\",\"msgModel\":{\"action\":\"\",\"anchorId\":\"\",\"anchorName\":\"\",\"method\":\"\",\"msgtype\":\"\",\"nobleId\":\"\",\"recommendCardType\":\"\",\"systemBubble\":\"\",\"trumpetMsg\":\"\",\"userId\":\"\",\"userName\":\"\"},\"nobleId\":\"0\",\"startColor\":\"\",\"type\":3,\"user_nicename\":\"爺傲灬奈我何丿\",\"vip_type\":0},\"userBean\":{\"avatar\":\"https://downs.yaoulive.com/20220915105003_c3dd5b27cc1d484dbfdade8ae14cb76e?imageView2/2/w/600/h/600\",\"avatar_thumb\":\"https://downs.yaoulive.com/20220915105003_c3dd5b27cc1d484dbfdade8ae14cb76e?imageView2/2/w/200/h/200\",\"car\":{\"id\":44,\"swf\":\"https://downs.yaoulive.com/%E4%BE%AF%E7%88%B5%C2%B7%E7%A5%9E%E5%8C%96%E9%BE%99%E9%B1%BC.svga\",\"swftime\":7,\"words\":\"駕馭着公爵專屬座駕【神化龍魚】霸氣進場了\"},\"dress\":{},\"fans\":0,\"follows\":0,\"goodName\":\"0\",\"guard_type\":0,\"hide\":false,\"hot_num\":\"75974\",\"id\":\"158329\",\"level\":58,\"level_anchor\":0,\"liang\":{\"name\":\"0\"},\"liangNameTip\":\"ID:158329\",\"lives\":0,\"medal_level'\":0,\"medal_name\":\"\",\"medal_name'\":\"\",\"noble_id\":\"0\",\"nub\":0,\"sex\":0,\"token_rong\":\"\",\"user_nicename\":\"爺傲灬奈我何丿\",\"vip\":{\"type\":0},\"vipType\":0}}", LiveEnterRoomBean.class);
- onEnterRoom(bean);
- });*/
+
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
@@ -3312,4 +3308,16 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mLiveChatAdapter.insertItem(bean);
}
}
+
+ /**
+ * 幸运天使
+ */
+ public void luckyAngel(MsgModel model){
+ if(mLiveChatAdapter!=null){
+ LiveChatBean bean = new LiveChatBean();
+ bean.setType(LiveChatBean.LUCKY_ANGEL);
+ bean.setMsgModel(model);
+ mLiveChatAdapter.insertItem(bean);
+ }
+ }
}
diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
index 96ddb899e..49037a066 100644
--- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
+++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
@@ -1622,6 +1622,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
+ /**
+ * 幸运天使
+ */
+ public void luckyAngel(MsgModel model){
+ if(mLiveRoomViewHolder != null){
+ mLiveRoomViewHolder.luckyAngel(model);
+ }
+ }
+
public void messageBottom() {
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.chatScrollToBottom();