diff --git a/common/src/main/java/com/yunbao/common/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java index 55259cf46..ff502b444 100644 --- a/common/src/main/java/com/yunbao/common/Constants.java +++ b/common/src/main/java/com/yunbao/common/Constants.java @@ -167,6 +167,7 @@ public class Constants { public static final String RECOMMEND_CARD_NOTIFY = "recommendCardNotify";//推荐卡通知消息 public static final String STAR_CHALLENGE_UPDATE = "starChallengeUpdate";//星级助力 public static final String AI_AUTOMATIC_SPEECH = "aiAutomaticSpeech";//机器人助手 + public static final String STAR_CHALLENGE_UPGRADE_NOTIFY = "starChallengeUpgradeNotify";//星级挑战成功 //游戏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 43f921d5e..7fc1f3d87 100644 --- a/common/src/main/java/com/yunbao/common/bean/MsgModel.java +++ b/common/src/main/java/com/yunbao/common/bean/MsgModel.java @@ -69,6 +69,21 @@ public class MsgModel extends BaseModel { @SerializedName("taskName2") private String taskName2; + + /** + * 星级挑战成功IM消息 + * + * @return + */ + @SerializedName("ancherName") + private String ancherName; + @SerializedName("competitionArea") + private String competitionArea; + @SerializedName("star") + private String star; + @SerializedName("liveUid") + private String liveUid; + public String getTaskNum() { return taskNum; } @@ -276,4 +291,36 @@ public class MsgModel extends BaseModel { return roleType; } } + + public String getAncherName() { + return ancherName; + } + + public void setAncherName(String ancherName) { + this.ancherName = ancherName; + } + + public String getCompetitionArea() { + return competitionArea; + } + + public void setCompetitionArea(String competitionArea) { + this.competitionArea = competitionArea; + } + + public String getStar() { + return star; + } + + public void setStar(String star) { + this.star = star; + } + + public String getLiveUid() { + return liveUid; + } + + public void setLiveUid(String liveUid) { + this.liveUid = liveUid; + } } diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index a0061ff5d..0aa793294 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -924,6 +924,6 @@ 總星值 助力人數 星级挑战%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 357db4ad4..af2da7e0a 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -849,6 +849,9 @@ public class LiveAudienceActivity extends LiveActivity { case AI_AUTOMATIC_SPEECH: manager.aiAutomaticSpeech(event.getAiAutomaticSpeechModel()); break; + case STAR_CHALLENGE_UPGRADE_NOTIFY: + manager.starChallengeUpgradeNotify(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 669fd5108..7185487b0 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -2,6 +2,7 @@ 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.STAR_CHALLENGE_UPGRADE_NOTIFY; import android.annotation.SuppressLint; import android.content.Context; @@ -335,7 +336,11 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } else if (bean.getType() == AI_AUTOMATIC_SPEECH) { //加载.9图聊天气泡 LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getAiAutomaticSpeechModel().getSystemBubble(), 1); - LiveTextRender.aiAutomaticSpeech(mContext,mTextView,bean.getAiAutomaticSpeechModel()); + LiveTextRender.aiAutomaticSpeech(mContext, mTextView, bean.getAiAutomaticSpeechModel()); + } else if (bean.getType() == STAR_CHALLENGE_UPGRADE_NOTIFY) { + //加载.9图聊天气泡 + LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystemBubble(), 1); + LiveTextRender.starChallengeUpgradeNotify(mContext, mTextView, bean.getMsgModel()); } else { if (bean.getBubble() != null && !bean.getBubble().equals("")) { //加载.9图聊天气泡 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 69a2df8ad..bc745ae80 100644 --- a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java +++ b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java @@ -19,6 +19,7 @@ public class LiveChatBean { public static final int RED_PACK = 5; 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; 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 f3f74f899..25843a68d 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -147,6 +147,7 @@ public class LiveAudienceEvent extends BaseModel { AT_MESSAGE(24, "@消息"), START_MESSAGE(25, "星级消息"), AI_AUTOMATIC_SPEECH(26, "机器人助手"), + STAR_CHALLENGE_UPGRADE_NOTIFY(27, "星级挑战成功") ; private int type; 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 56ca5b216..c0252f72d 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -488,6 +488,16 @@ public class SocketRyClient { .setType(LiveAudienceEvent.LiveAudienceType.AI_AUTOMATIC_SPEECH) .setAiAutomaticSpeechModel(aiAutomaticSpeechModel)); break; + case Constants.STAR_CHALLENGE_UPGRADE_NOTIFY: + SocketModel starChallengeUpgradeNotify = GsonUtils.fromJson(socketMsg, SocketModel.class); + List starChallengeUpgradeNotifyMsg = starChallengeUpgradeNotify.getMsg(); + if (starChallengeUpgradeNotifyMsg.size() > 0) { + + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.STAR_CHALLENGE_UPGRADE_NOTIFY) + .setMsgModel(starChallengeUpgradeNotifyMsg.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 755170000..f7d5ce612 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java @@ -27,6 +27,7 @@ import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; import com.yunbao.common.bean.AiAutomaticSpeechModel; import com.yunbao.common.bean.LevelBean; +import com.yunbao.common.bean.MsgModel; import com.yunbao.common.custom.VerticalImageSpan; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.utils.DpUtil; @@ -93,6 +94,28 @@ public class LiveTextRender { textView.setText(spannableString); } + /** + * 星级挑战成功Im消息 + * + * @param activity + * @param textView + * @param model + */ + public static void starChallengeUpgradeNotify(Context activity, TextView textView, MsgModel model) { + String star = activity.getString(R.string.star); + String starString = String.format(activity.getString(R.string.star_success), model.getAncherName(), model.getCompetitionArea(), model.getStar()); + SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(); + star = model.getStar() + star; + int ancherNameStart = starString.indexOf(model.getAncherName()); + int starStart = starString.indexOf(star); + spannableStringBuilder.append(starString); + spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#6ffeff")), + ancherNameStart, ancherNameStart + model.getAncherName().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#fcfe35")), + starStart, starStart + star.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + textView.setText(spannableStringBuilder); + } + public static void aiAutomaticSpeech(Context activity, TextView textView, AiAutomaticSpeechModel model) { ImgLoader.displayDrawable(activity, model.getIcon(), new ImgLoader.DrawableCallback() { @Override @@ -128,7 +151,7 @@ public class LiveTextRender { String mContext = content; for (String name : userNames) { name = "@" + name; - while (mContext.contains(name)&&!TextUtils.isEmpty(mContext)) { + while (mContext.contains(name) && !TextUtils.isEmpty(mContext)) { int index = mContext.indexOf(name); int end = index + name.length(); int endIndex = startIndex + name.length(); 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 4c6ef59ed..b003033b8 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -3261,12 +3261,25 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * @param model */ public void aiAutomaticSpeech(AiAutomaticSpeechModel model) { - if (mLiveChatAdapter != null){ + if (mLiveChatAdapter != null) { LiveChatBean bean = new LiveChatBean(); bean.setType(LiveChatBean.AI_AUTOMATIC_SPEECH); bean.setAiAutomaticSpeechModel(model); mLiveChatAdapter.insertItem(bean); } + } + /** + * 星级挑战成功 + * + * @param model + */ + public void starChallengeUpgradeNotify(MsgModel model) { + if (mLiveChatAdapter != null) { + LiveChatBean bean = new LiveChatBean(); + bean.setType(LiveChatBean.STAR_CHALLENGE_UPGRADE_NOTIFY); + 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 79dcfe30d..c1b360f77 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -1591,4 +1591,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.aiAutomaticSpeech(model); } } + + /** + * 星级挑战成功 + * + * @param msgModel + */ + public void starChallengeUpgradeNotify(MsgModel msgModel) { + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.starChallengeUpgradeNotify(msgModel); + } + } }