diff --git a/common/src/main/java/com/yunbao/common/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java
index 91deaaf15..c2835c75e 100644
--- a/common/src/main/java/com/yunbao/common/Constants.java
+++ b/common/src/main/java/com/yunbao/common/Constants.java
@@ -164,6 +164,7 @@ public class Constants {
public static final String SOCKET_PRIZE_POOL_WIN = "jackpotWin";//奖池中奖
public static final String SOCKET_PRIZE_POOL_UP = "jackpotUp";//奖池升级
public static final String SOCKET_HOUR = "SendHourChart";//小时榜更新
+ public static final String RECOMMEND_CARD_NOTIFY = "recommendCardNotify";//推荐卡通知消息
//游戏socket
public static final String SOCKET_GAME_ZJH = "startGame";//炸金花
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 8e48a5e4a..052b06719 100644
--- a/common/src/main/java/com/yunbao/common/bean/MsgModel.java
+++ b/common/src/main/java/com/yunbao/common/bean/MsgModel.java
@@ -19,7 +19,7 @@ public class MsgModel extends BaseModel {
private String method = "";
@SerializedName("user_id")
private String userId = "";
- @SerializedName("user_name")
+ @SerializedName(value = "user_name", alternate = {"userName"})
private String userName = "";
@SerializedName("noble_id")
private String nobleId = "";
@@ -28,6 +28,73 @@ public class MsgModel extends BaseModel {
@SerializedName("anchor_id")
private String anchorId = "";
+ /**
+ * 推荐消息
+ * _method_ : recommendCardNotify
+ * action : 0
+ * msgtype : 1
+ * recommendCardType : 2
+ * userName : 哈哈哈
+ * anchorName : what-hap
+ * systemBubble : https://downs.yaoulive.com/20220721/1c5448119a159fcb154dd3fefe0a0f36.png
+ */
+
+ @SerializedName("action")
+ private String action = "";
+ @SerializedName("msgtype")
+ private String msgtype = "";
+ @SerializedName("recommendCardType")
+ private String recommendCardType = "";
+ @SerializedName("anchorName")
+ private String anchorName = "";
+ @SerializedName("systemBubble")
+ private String systemBubble = "";
+
+ public String getAction() {
+ return action;
+ }
+
+ public MsgModel setAction(String action) {
+ this.action = action;
+ return this;
+ }
+
+ public String getMsgtype() {
+ return msgtype;
+ }
+
+ public MsgModel setMsgtype(String msgtype) {
+ this.msgtype = msgtype;
+ return this;
+ }
+
+ public String getRecommendCardType() {
+ return recommendCardType;
+ }
+
+ public MsgModel setRecommendCardType(String recommendCardType) {
+ this.recommendCardType = recommendCardType;
+ return this;
+ }
+
+ public String getAnchorName() {
+ return anchorName;
+ }
+
+ public MsgModel setAnchorName(String anchorName) {
+ this.anchorName = anchorName;
+ return this;
+ }
+
+ public String getSystemBubble() {
+ return systemBubble;
+ }
+
+ public MsgModel setSystemBubble(String systemBubble) {
+ this.systemBubble = systemBubble;
+ return this;
+ }
+
public String getMethod() {
return method;
}
diff --git a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java
index 0e006fcce..fc8455924 100644
--- a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java
+++ b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java
@@ -126,11 +126,8 @@ public class ImgLoader {
}
public static void displayDrawable(Context context, String url, final DrawableCallback callback) {
- if (!contextIsExist(context)) {
- return;
- }
- if (TextUtils.isEmpty(url)) {
+ if (TextUtils.isEmpty(url)||!contextIsExist(context)) {
if (callback != null)
callback.onLoadFailed();
} else {
@@ -143,6 +140,13 @@ public class ImgLoader {
}
}
+ @Override
+ public void onLoadFailed(@Nullable Drawable errorDrawable) {
+ super.onLoadFailed(errorDrawable);
+ if (callback != null)
+ callback.onLoadFailed();
+ }
+
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml
index e67596f74..54809f669 100644
--- a/common/src/main/res/values/strings.xml
+++ b/common/src/main/res/values/strings.xml
@@ -903,5 +903,8 @@
超皇
無法前往神秘人的個人主頁。
神秘人
+ 昭告天下!
+ 昭告天下! %s 向所有人推薦了主播 %s , 一眼萬年情之所鐘!
+ 昭告天下! %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 a5bb51a47..4b9e6b384 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
@@ -54,6 +54,7 @@ import com.yunbao.live.R;
import com.yunbao.live.adapter.VerticalPagerAdapter;
import com.yunbao.live.bean.ImUserBean;
import com.yunbao.live.bean.LiveBean;
+import com.yunbao.live.bean.LiveChatBean;
import com.yunbao.live.dialog.LiveFansFragment;
import com.yunbao.live.dialog.LiveGiftDialogFragment;
import com.yunbao.live.dialog.LiveHDDialogFragment;
@@ -798,6 +799,14 @@ public class LiveAudienceActivity extends LiveActivity {
case TRUMPET_NOTIFY:
manager.showFullScreen(event.getMsgModel());
break;
+ case RECOMMEND_CARD_NOTIFY:
+ LiveChatBean chatBean = new LiveChatBean();
+ chatBean.setMsgModel(event.getMsgModel());
+ chatBean.setType(LiveChatBean.RECOMMEND_CARD_NOTIFY);
+ chatBean.setBubble(event.getMsgModel().getSystemBubble());
+ manager.onChat(chatBean, 1);
+
+ break;
}
@@ -857,7 +866,8 @@ public class LiveAudienceActivity extends LiveActivity {
/**
* 跳转当前页面
*/
- public static void forward(Context context, LiveBean liveBean, int liveType, int liveTypeVal, String key, int position, int liveSdk) {
+ public static void forward(Context context, LiveBean liveBean, int liveType,
+ int liveTypeVal, String key, int position, int liveSdk) {
Intent intent = new Intent(context, LiveAudienceActivity.class);
intent.putExtra(Constants.LIVE_BEAN, liveBean);
intent.putExtra(Constants.LIVE_TYPE, liveType);
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 6969580d6..ae7081362 100644
--- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
+++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
@@ -37,12 +37,14 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY;
+
/**
* Created by cxf on 2018/10/10.
*/
public class LiveChatAdapter extends RecyclerView.Adapter {
- public final static int MSG_HOUR_RANK_CHANGE=-100;//收到小时榜推送,发送一条弹幕
+ public final static int MSG_HOUR_RANK_CHANGE = -100;//收到小时榜推送,发送一条弹幕
private Context mContext;
private List mList;
@@ -284,7 +286,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
} else if (bean.getType() == LiveChatBean.SYSTEM) {
boolean isContains = false;
for (LiveChatBean model : mList) {
- if (!TextUtils.isEmpty(model.getContent())&&model.getContent().contains("堅決維護青少年群體精神文明健康")) {
+ if (!TextUtils.isEmpty(model.getContent()) && model.getContent().contains("堅決維護青少年群體精神文明健康")) {
isContains = true;
}
}
@@ -320,11 +322,15 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
mTextView.setText(R.string.automatic_chat);
bean.setHeart(position);
}
- }else if(bean.getType()==MSG_HOUR_RANK_CHANGE){
- mBg.setBackgroundResource(R.drawable.bg_chat_automatic_item);
- mTextView.setText(bean.getContent());
- bean.setHeart(position);
- }else {
+ } else if (bean.getType() == MSG_HOUR_RANK_CHANGE) {
+ mBg.setBackgroundResource(R.drawable.bg_chat_automatic_item);
+ mTextView.setText(bean.getContent());
+ bean.setHeart(position);
+ } else if (bean.getType() == RECOMMEND_CARD_NOTIFY) {
+ //加载.9图聊天气泡
+ LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
+ LiveTextRender.recommendCardNotify(mContext, mTextView, bean);
+ } 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 7b69a2807..f830fb020 100644
--- a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java
+++ b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java
@@ -1,6 +1,7 @@
package com.yunbao.live.bean;
import com.alibaba.fastjson.annotation.JSONField;
+import com.yunbao.common.bean.MsgModel;
/**
* Created by cxf on 2017/8/22.
@@ -14,6 +15,7 @@ public class LiveChatBean {
public static final int ENTER_ROOM = 3;
public static final int LIGHT = 4;
public static final int RED_PACK = 5;
+ public static final int RECOMMEND_CARD_NOTIFY = 10;
private String id;
private String userNiceName;
@@ -37,6 +39,16 @@ public class LiveChatBean {
private String anchorName;
private String prankIcon;
private String hot_card;
+ private MsgModel msgModel = new MsgModel();//自定义消息体
+
+ public MsgModel getMsgModel() {
+ return msgModel;
+ }
+
+ public LiveChatBean setMsgModel(MsgModel msgModel) {
+ this.msgModel = msgModel;
+ return this;
+ }
public String getHot_card() {
return hot_card;
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 42f04d017..58b195025 100644
--- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
+++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
@@ -129,7 +129,8 @@ public class LiveAudienceEvent extends BaseModel {
POPULAR(17, "人气票任务"),
NOTICE(18, "系统通知"),
ONLINE(19, "在线客服"),
- TRUMPET_NOTIFY(20, "全服喇叭");
+ TRUMPET_NOTIFY(20, "全服喇叭"),
+ RECOMMEND_CARD_NOTIFY(21, "贵族推荐通知");
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 05c0657ff..d4e5074fd 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
@@ -459,6 +459,16 @@ public class SocketRyClient {
.setMsgModel(msg.get(0)));
}
break;
+ case Constants.RECOMMEND_CARD_NOTIFY://推荐卡消息通知
+ SocketModel recommendCardNotifyModel = GsonUtils.fromJson(socketMsg, SocketModel.class);
+ List recommendCardNotifyMsg = recommendCardNotifyModel.getMsg();
+ if (recommendCardNotifyMsg.size() > 0) {
+
+ Bus.get().post(new LiveAudienceEvent()
+ .setType(LiveAudienceEvent.LiveAudienceType.RECOMMEND_CARD_NOTIFY)
+ .setMsgModel(recommendCardNotifyMsg.get(0)));
+ }
+ 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 10b77277c..dfa750f5a 100644
--- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
+++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
@@ -6,8 +6,8 @@ import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
-import androidx.core.content.ContextCompat;
import android.text.Spannable;
+import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.AbsoluteSizeSpan;
@@ -20,6 +20,8 @@ import android.view.View.MeasureSpec;
import android.widget.ImageView;
import android.widget.TextView;
+import androidx.core.content.ContextCompat;
+
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
@@ -57,6 +59,38 @@ public class LiveTextRender {
sFontSizeSpan3 = new AbsoluteSizeSpan(14, true);
}
+ /**
+ * 直播间推荐卡
+ *
+ * @param textView
+ * @param bean
+ */
+ public static void recommendCardNotify(Context context, TextView textView, LiveChatBean bean) {
+ String recommend;
+ Drawable drawable;
+ if (TextUtils.equals(bean.getMsgModel().getRecommendCardType(), "1")) {
+ recommend = context.getString(R.string.emperor_hint);
+ drawable = context.getResources().getDrawable(R.mipmap.emperor_rom);
+ } else {
+ recommend = context.getString(R.string.better_emperor_hint);
+ drawable = context.getResources().getDrawable(R.mipmap.super_emperor_rom);
+ }
+
+ String recommendCard = String.format(recommend, bean.getMsgModel().getUserName(), bean.getMsgModel().getAnchorName());
+ SpannableString spannableString = new SpannableString(recommendCard);
+ ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#ffff00"));
+ ForegroundColorSpan colorSpan2 = new ForegroundColorSpan(Color.parseColor("#a1f3ff"));
+
+ //18 43
+ drawable.setBounds(0, 0, DpUtil.dp2px(46), DpUtil.dp2px(23));
+ //用这个drawable对象代替字符串easy
+ ImageSpan span = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE);
+ //包括0但是不包括"easy".length()即:4。[0,4)。值得注意的是当我们复制这个图片的时候,实际是复制了"easy"这个字符串。
+ spannableString.setSpan(span, recommendCard.indexOf("!") + 1, recommendCard.indexOf("!") + 2, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
+ spannableString.setSpan(colorSpan, spannableString.getSpanStart(span), spannableString.getSpanStart(span) + bean.getMsgModel().getUserName().length() + 1, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
+ spannableString.setSpan(colorSpan2, recommendCard.lastIndexOf(context.getString(R.string.anchor)) + 2, recommendCard.lastIndexOf(","), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
+ textView.setText(spannableString);
+ }
/**
* 生成前缀
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 43d51d0d1..7d834464f 100644
--- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
+++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
@@ -566,6 +566,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void onChat(LiveChatBean bean, int index) {
+ Log.e("LiveChatBean", GsonUtils.toJson(bean));
if (bean.getType() == 1) {
if (!bean.getContent().contains(mLiveBean.getUserNiceName())) {
return;
diff --git a/live/src/main/res/mipmap-xxxhdpi/emperor_rom.png b/live/src/main/res/mipmap-xxxhdpi/emperor_rom.png
new file mode 100644
index 000000000..17828e06e
Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/emperor_rom.png differ
diff --git a/live/src/main/res/mipmap-xxxhdpi/super_emperor_rom.png b/live/src/main/res/mipmap-xxxhdpi/super_emperor_rom.png
new file mode 100644
index 000000000..16e64b374
Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/super_emperor_rom.png differ