盲盒礼物具体业务逻辑的构建,IM消息的构建

This commit is contained in:
18401019693 2023-05-25 13:40:49 +08:00
parent 1f7aef91a8
commit b4dc035a1b
17 changed files with 941 additions and 158 deletions

View File

@ -0,0 +1,558 @@
package com.yunbao.common.event;
import com.google.gson.annotations.SerializedName;
import com.yunbao.common.bean.BaseModel;
public class SendBlindGiftEvent extends BaseModel {
@SerializedName("uid")
private String uid;
@SerializedName("giftid")
private String giftid;
@SerializedName("type")
private String type;
@SerializedName("mark")
private String mark;
@SerializedName("wrap_gift_num")
private String wrapGiftNum;
@SerializedName("giftcount")
private String giftcount;
@SerializedName("totalcoin")
private String totalcoin;
@SerializedName("giftname")
private String giftname;
@SerializedName("giftnameen")
private String giftnameen;
@SerializedName("gifticon")
private String gifticon;
@SerializedName("swftime")
private String swftime;
@SerializedName("swftype")
private String swftype;
@SerializedName("swf")
private String swf;
@SerializedName("level")
private String level;
@SerializedName("medal_name")
private String medalName;
@SerializedName("medal_level")
private String medalLevel;
@SerializedName("coin")
private String coin;
@SerializedName("gold")
private String gold;
@SerializedName("votestotal")
private String votestotal;
@SerializedName("medalRankNum")
private String medalRankNum;
@SerializedName("ispk")
private String ispk;
@SerializedName("pkuid")
private boolean pkuid;
@SerializedName("pkuid1")
private String pkuid1;
@SerializedName("pkuid2")
private String pkuid2;
@SerializedName("pktotal1")
private String pktotal1;
@SerializedName("pktotal2")
private String pktotal2;
@SerializedName("active_total")
private String activeTotal;
@SerializedName("blind_box_status")
private boolean blindBoxStatus;
@SerializedName("gift_id")
private String giftId;
@SerializedName("gift_type")
private String giftType;
@SerializedName("needcoin")
private String needcoin;
@SerializedName("gift_msg")
private String giftMsg;
@SerializedName("gift_notification")
private boolean giftNotification;
@SerializedName("gift_colour")
private String giftColour;
@SerializedName("box_type")
private String boxType;
@SerializedName("box_type_name")
private String boxTypeName;
@SerializedName("action")
private String action;
@SerializedName("dress_notification")
private boolean dressNotification;
@SerializedName("dress_type")
private Object dressType;
@SerializedName("dress_id")
private Object dressId;
@SerializedName("dress_name")
private String dressName;
@SerializedName("display_src")
private Object displaySrc;
@SerializedName("effect_src")
private Object effectSrc;
@SerializedName("dress_description")
private Object dressDescription;
@SerializedName("noble_dress")
private Object nobleDress;
@SerializedName("dress_msg")
private String dressMsg;
@SerializedName("dress_colour")
private String dressColour;
@SerializedName("dress_threshold_value")
private String dressThresholdValue;
@SerializedName("live_gift_notify")
private String liveGiftNotify;
@SerializedName("userNiceName")
private String userNiceName;
public String getUserNiceName() {
return userNiceName;
}
public SendBlindGiftEvent setUserNiceName(String userNiceName) {
this.userNiceName = userNiceName;
return this;
}
public String getUid() {
return uid;
}
public SendBlindGiftEvent setUid(String uid) {
this.uid = uid;
return this;
}
public String getGiftid() {
return giftid;
}
public SendBlindGiftEvent setGiftid(String giftid) {
this.giftid = giftid;
return this;
}
public String getType() {
return type;
}
public SendBlindGiftEvent setType(String type) {
this.type = type;
return this;
}
public String getMark() {
return mark;
}
public SendBlindGiftEvent setMark(String mark) {
this.mark = mark;
return this;
}
public String getWrapGiftNum() {
return wrapGiftNum;
}
public SendBlindGiftEvent setWrapGiftNum(String wrapGiftNum) {
this.wrapGiftNum = wrapGiftNum;
return this;
}
public String getGiftcount() {
return giftcount;
}
public SendBlindGiftEvent setGiftcount(String giftcount) {
this.giftcount = giftcount;
return this;
}
public String getTotalcoin() {
return totalcoin;
}
public SendBlindGiftEvent setTotalcoin(String totalcoin) {
this.totalcoin = totalcoin;
return this;
}
public String getGiftname() {
return giftname;
}
public SendBlindGiftEvent setGiftname(String giftname) {
this.giftname = giftname;
return this;
}
public String getGiftnameen() {
return giftnameen;
}
public SendBlindGiftEvent setGiftnameen(String giftnameen) {
this.giftnameen = giftnameen;
return this;
}
public String getGifticon() {
return gifticon;
}
public SendBlindGiftEvent setGifticon(String gifticon) {
this.gifticon = gifticon;
return this;
}
public String getSwftime() {
return swftime;
}
public SendBlindGiftEvent setSwftime(String swftime) {
this.swftime = swftime;
return this;
}
public String getSwftype() {
return swftype;
}
public SendBlindGiftEvent setSwftype(String swftype) {
this.swftype = swftype;
return this;
}
public String getSwf() {
return swf;
}
public SendBlindGiftEvent setSwf(String swf) {
this.swf = swf;
return this;
}
public String getLevel() {
return level;
}
public SendBlindGiftEvent setLevel(String level) {
this.level = level;
return this;
}
public String getMedalName() {
return medalName;
}
public SendBlindGiftEvent setMedalName(String medalName) {
this.medalName = medalName;
return this;
}
public String getMedalLevel() {
return medalLevel;
}
public SendBlindGiftEvent setMedalLevel(String medalLevel) {
this.medalLevel = medalLevel;
return this;
}
public String getCoin() {
return coin;
}
public SendBlindGiftEvent setCoin(String coin) {
this.coin = coin;
return this;
}
public String getGold() {
return gold;
}
public SendBlindGiftEvent setGold(String gold) {
this.gold = gold;
return this;
}
public String getVotestotal() {
return votestotal;
}
public SendBlindGiftEvent setVotestotal(String votestotal) {
this.votestotal = votestotal;
return this;
}
public String getMedalRankNum() {
return medalRankNum;
}
public SendBlindGiftEvent setMedalRankNum(String medalRankNum) {
this.medalRankNum = medalRankNum;
return this;
}
public String getIspk() {
return ispk;
}
public SendBlindGiftEvent setIspk(String ispk) {
this.ispk = ispk;
return this;
}
public boolean isPkuid() {
return pkuid;
}
public SendBlindGiftEvent setPkuid(boolean pkuid) {
this.pkuid = pkuid;
return this;
}
public String getPkuid1() {
return pkuid1;
}
public SendBlindGiftEvent setPkuid1(String pkuid1) {
this.pkuid1 = pkuid1;
return this;
}
public String getPkuid2() {
return pkuid2;
}
public SendBlindGiftEvent setPkuid2(String pkuid2) {
this.pkuid2 = pkuid2;
return this;
}
public String getPktotal1() {
return pktotal1;
}
public SendBlindGiftEvent setPktotal1(String pktotal1) {
this.pktotal1 = pktotal1;
return this;
}
public String getPktotal2() {
return pktotal2;
}
public SendBlindGiftEvent setPktotal2(String pktotal2) {
this.pktotal2 = pktotal2;
return this;
}
public String getActiveTotal() {
return activeTotal;
}
public SendBlindGiftEvent setActiveTotal(String activeTotal) {
this.activeTotal = activeTotal;
return this;
}
public boolean isBlindBoxStatus() {
return blindBoxStatus;
}
public SendBlindGiftEvent setBlindBoxStatus(boolean blindBoxStatus) {
this.blindBoxStatus = blindBoxStatus;
return this;
}
public String getGiftId() {
return giftId;
}
public SendBlindGiftEvent setGiftId(String giftId) {
this.giftId = giftId;
return this;
}
public String getGiftType() {
return giftType;
}
public SendBlindGiftEvent setGiftType(String giftType) {
this.giftType = giftType;
return this;
}
public String getNeedcoin() {
return needcoin;
}
public SendBlindGiftEvent setNeedcoin(String needcoin) {
this.needcoin = needcoin;
return this;
}
public String getGiftMsg() {
return giftMsg;
}
public SendBlindGiftEvent setGiftMsg(String giftMsg) {
this.giftMsg = giftMsg;
return this;
}
public boolean isGiftNotification() {
return giftNotification;
}
public SendBlindGiftEvent setGiftNotification(boolean giftNotification) {
this.giftNotification = giftNotification;
return this;
}
public String getGiftColour() {
return giftColour;
}
public SendBlindGiftEvent setGiftColour(String giftColour) {
this.giftColour = giftColour;
return this;
}
public String getBoxType() {
return boxType;
}
public SendBlindGiftEvent setBoxType(String boxType) {
this.boxType = boxType;
return this;
}
public String getBoxTypeName() {
return boxTypeName;
}
public SendBlindGiftEvent setBoxTypeName(String boxTypeName) {
this.boxTypeName = boxTypeName;
return this;
}
public String getAction() {
return action;
}
public SendBlindGiftEvent setAction(String action) {
this.action = action;
return this;
}
public boolean isDressNotification() {
return dressNotification;
}
public SendBlindGiftEvent setDressNotification(boolean dressNotification) {
this.dressNotification = dressNotification;
return this;
}
public Object getDressType() {
return dressType;
}
public SendBlindGiftEvent setDressType(Object dressType) {
this.dressType = dressType;
return this;
}
public Object getDressId() {
return dressId;
}
public SendBlindGiftEvent setDressId(Object dressId) {
this.dressId = dressId;
return this;
}
public String getDressName() {
return dressName;
}
public SendBlindGiftEvent setDressName(String dressName) {
this.dressName = dressName;
return this;
}
public Object getDisplaySrc() {
return displaySrc;
}
public SendBlindGiftEvent setDisplaySrc(Object displaySrc) {
this.displaySrc = displaySrc;
return this;
}
public Object getEffectSrc() {
return effectSrc;
}
public SendBlindGiftEvent setEffectSrc(Object effectSrc) {
this.effectSrc = effectSrc;
return this;
}
public Object getDressDescription() {
return dressDescription;
}
public SendBlindGiftEvent setDressDescription(Object dressDescription) {
this.dressDescription = dressDescription;
return this;
}
public Object getNobleDress() {
return nobleDress;
}
public SendBlindGiftEvent setNobleDress(Object nobleDress) {
this.nobleDress = nobleDress;
return this;
}
public String getDressMsg() {
return dressMsg;
}
public SendBlindGiftEvent setDressMsg(String dressMsg) {
this.dressMsg = dressMsg;
return this;
}
public String getDressColour() {
return dressColour;
}
public SendBlindGiftEvent setDressColour(String dressColour) {
this.dressColour = dressColour;
return this;
}
public String getDressThresholdValue() {
return dressThresholdValue;
}
public SendBlindGiftEvent setDressThresholdValue(String dressThresholdValue) {
this.dressThresholdValue = dressThresholdValue;
return this;
}
public String getLiveGiftNotify() {
return liveGiftNotify;
}
public SendBlindGiftEvent setLiveGiftNotify(String liveGiftNotify) {
this.liveGiftNotify = liveGiftNotify;
return this;
}
}

Binary file not shown.

View File

@ -31,6 +31,7 @@ import com.yunbao.common.bean.NobleRankHideUserListModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.CoinChangeEvent;
import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.event.SendBlindGiftEvent;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.interfaces.KeyBoardHeightChangeListener;
@ -40,7 +41,6 @@ import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ProcessImageUtil;
import com.yunbao.common.utils.SVGAViewUtils;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.utils.formatBigNum;
import com.yunbao.live.R;
import com.yunbao.live.bean.GuardUserBean;
@ -317,8 +317,8 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 收到礼物消息
*/
@Override
public void onSendGift(LiveReceiveGiftBean bean) {
public void onSendGift(LiveReceiveGiftBean bean, SendBlindGiftEvent event) {
if (event == null) {
//购买守护
if (bean.ismTypeBuyGuard()) {
if (mLiveRoomViewHolder != null) {
@ -335,6 +335,8 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
}
}
}
}
@ -1362,6 +1364,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
fragment.setArguments(bundle);
fragment.show(getSupportFragmentManager(), "LiveGuardBuyDialogFragment");
}
/**
* 打开购买守护的弹窗
*/

View File

@ -51,6 +51,7 @@ import com.yunbao.common.bean.MicUserBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.NotCancelableDialog;
import com.yunbao.common.event.LoginInvalidEvent;
import com.yunbao.common.event.SendBlindGiftEvent;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
@ -73,6 +74,7 @@ import com.yunbao.common.views.LiveNewWishListPopup;
import com.yunbao.common.views.LiveRobotSettingCustomPopup;
import com.yunbao.faceunity.FaceManager;
import com.yunbao.live.R;
import com.yunbao.live.bean.LiveChatBean;
import com.yunbao.live.bean.LiveGuardInfo;
import com.yunbao.live.bean.LiveKsyConfigBean;
import com.yunbao.live.bean.LiveReceiveGiftBean;
@ -1464,7 +1466,21 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
@Override
public void onSendGift(LiveReceiveGiftBean bean) {
public void onSendGift(LiveReceiveGiftBean bean, SendBlindGiftEvent event) {
if (event!=null){
//插入盲盒礼物消息
bean.getLiveChatBean().setType(LiveChatBean.BLIND_BOX);
bean.getLiveChatBean().setContent(event.getGiftMsg());
bean.getLiveChatBean().setGiftName(event.getGiftname());
bean.getLiveChatBean().setUserNiceName(event.getUserNiceName());
if (mLiveRoomViewHolder != null) {
if (bean.getmLiveUId().equals(bean.getRoomnum())) {
mLiveRoomViewHolder.insertChat(bean.getLiveChatBean(), 1);
}
mLiveRoomViewHolder.showGiftMessage(bean, false);
mLiveRoomViewHolder.updataWishList(bean.getGiftId(), bean.getGiftCount());
}
}else {
//购买守护
if (bean.ismTypeBuyGuard()) {
if (mLiveRoomViewHolder != null) {
@ -1483,6 +1499,8 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
}
}
private void printLog(String content) {
if (mLogFile == null) {
File dir = new File(CommonAppConfig.LOG_PATH);

View File

@ -27,11 +27,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
@ -49,7 +47,6 @@ import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ClipPathCircleImage;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAudienceActivity;
@ -360,6 +357,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
mTextView.setText(builder);
} else if (bean.getType() == -10) {
mBg.setBackground(null);
} else if (bean.getType() == LiveChatBean.BLIND_BOX) {
Log.e("BLIND_BOX", bean.toString());
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
new LiveTextRender().blindBox(mContext, mTextView, bean);
} else if (bean.getType() == LiveChatBean.SYSTEM) {
boolean isContains = false;
for (LiveChatBean model : mList) {

View File

@ -26,7 +26,7 @@ public class LiveChatBean {
public static final int SYSTEM3_COLOR = 108;//带颜色的系统消息,格式 XXXX<font color='#FF8E43'>YYY</font>
public static final int XYD_COMPLETE = 207;//心愿单完成通知
public static final int WISH_LIST_PROGRESS = 307;//心愿单进度通知
public static final int BLIND_BOX = 409;//盲盒礼物消息
private String id;
@ -52,6 +52,17 @@ public class LiveChatBean {
private String prankIcon;
private String hot_card;
private MsgModel msgModel = new MsgModel();//自定义消息体
private String giftName;
public String getGiftName() {
return giftName;
}
public LiveChatBean setGiftName(String giftName) {
this.giftName = giftName;
return this;
}
private AiAutomaticSpeechModel aiAutomaticSpeechModel = new AiAutomaticSpeechModel();//机器人消息体
public AiAutomaticSpeechModel getAiAutomaticSpeechModel() {
@ -369,4 +380,45 @@ public class LiveChatBean {
public void setMedalLevelImageUrl(String medalLevelImageUrl) {
this.medalLevelImageUrl = medalLevelImageUrl;
}
@Override
public String toString() {
return "LiveChatBean{" +
"NORMAL=" + NORMAL +
", id='" + id + '\'' +
", userNiceName='" + userNiceName + '\'' +
", level=" + level +
", content='" + content + '\'' +
", heart=" + heart +
", type=" + type +
", liangName='" + liangName + '\'' +
", vipType=" + vipType +
", guardType=" + guardType +
", anchor=" + anchor +
", manager=" + manager +
", medalNmae='" + medalNmae + '\'' +
", medalLevelImageUrl='" + medalLevelImageUrl + '\'' +
", bubble='" + bubble + '\'' +
", medal='" + medal + '\'' +
", medal_new='" + medal_new + '\'' +
", medal_honor='" + medal_honor + '\'' +
", hot_num='" + hot_num + '\'' +
", good_nub='" + good_nub + '\'' +
", anchorName='" + anchorName + '\'' +
", prankIcon='" + prankIcon + '\'' +
", hot_card='" + hot_card + '\'' +
", msgModel=" + msgModel +
", giftName='" + giftName + '\'' +
", aiAutomaticSpeechModel=" + aiAutomaticSpeechModel +
", nobleId='" + nobleId + '\'' +
", nobleIcon='" + nobleIcon + '\'' +
", bubbleSrc='" + bubbleSrc + '\'' +
", startColor='" + startColor + '\'' +
", endColor='" + endColor + '\'' +
", contentColor='" + contentColor + '\'' +
", atUserName='" + atUserName + '\'' +
", atUserID='" + atUserID + '\'' +
", isAttention=" + isAttention +
'}';
}
}

View File

@ -40,6 +40,10 @@ import com.alibaba.android.arouter.launcher.ARouter;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.BlindBoxInfoModel;
@ -47,6 +51,7 @@ import com.yunbao.common.bean.LiveGiftBean;
import com.yunbao.common.bean.LiveGiftBean2;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.event.SendBlindGiftEvent;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.live.LiveNetManager;
@ -58,6 +63,7 @@ import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.NobleUtil;
import com.yunbao.common.utils.SVGAViewUtils;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
@ -141,7 +147,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
private int isContactGift = 0;
DialogInterface.OnDismissListener onDismissListener;
DialogInterface.OnShowListener onShowListener;
private SVGAImageView blindSvga;
@Override
protected int getLayoutId() {
@ -176,6 +182,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
Bus.getOff(this);
if (onDismissListener != null) {
onDismissListener.onDismiss(dialog);
}
@ -196,6 +203,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Bus.getOn(this);
mCoin = (TextView) mRootView.findViewById(R.id.coin);
mTvGoldCoin = (TextView) mRootView.findViewById(R.id.goldCoin);
mTvGoCharge = (TextView) mRootView.findViewById(R.id.go_charge);
@ -207,6 +215,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
progressBlind1 = mRootView.findViewById(R.id.progress_blind2);
progressBlind2 = mRootView.findViewById(R.id.progress_blind3);
mArrow = mRootView.findViewById(R.id.arrow);
blindSvga = mRootView.findViewById(R.id.blind_svga);
mBtnSend = mRootView.findViewById(R.id.btn_send);
mBtnSendGroup = mRootView.findViewById(R.id.btn_send_group);
mBtnSendLian = mRootView.findViewById(R.id.btn_send_lian);
@ -409,7 +418,6 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
upData();
mCoin.setText(obj.getString("coin"));
mTvGoldCoin.setText(obj.getString("gold"));
Bus.getOn(LiveGiftDialogFragment.this);
}
}
@ -701,6 +709,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
mBtnChooseCount.setVisibility(View.VISIBLE);
mArrow.setVisibility(View.VISIBLE);
mBtnSend.setBackground(mDrawable1);
mBtnChooseCount.setEnabled(true);
}
if (bean.getType() == 5) {
@ -722,8 +731,10 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
* @param blindBoxType
*/
private StringBuffer blindGiftNamesBuffer = null;
private int blindBoxType;
private void showBlindProgress(int blindBoxType) {
this.blindBoxType = blindBoxType;
blindGiftNamesBuffer = new StringBuffer();
BlindBoxInfoModel model = null;
for (BlindBoxInfoModel boxInfoModel : blindBoxInfoModels) {
@ -732,6 +743,22 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
}
}
if (model == null) return;
new SVGAParser(mContext).decodeFromAssets("hdsn.svga", new SVGAParser.ParseCompletion() {
@Override
public void onComplete(SVGAVideoEntity videoItem) {
SVGADrawable drawable = new SVGADrawable(videoItem);
blindSvga.setImageDrawable(drawable);
SVGAViewUtils.playEndClear(blindSvga, false);
}
@Override
public void onError() {
Log.e("errqs", "errl");
}
}, null);
mArrow.setVisibility(View.GONE);
mBtnChooseCount.setEnabled(false);
mVipGold.setVisibility(View.GONE);
blindBox.setVisibility(View.VISIBLE);
WindowManager.LayoutParams params = getDialog().getWindow().getAttributes();
@ -1016,4 +1043,73 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSendBlindGiftEvent(SendBlindGiftEvent event) {
BlindBoxInfoModel model = null;
for (int i = 0; i < blindBoxInfoModels.size(); i++) {
if (TextUtils.equals(blindBoxInfoModels.get(i).getBlindBoxType(), event.getBoxType())) {
blindBoxInfoModels.get(i).setDressThresholdValue(event.getDressThresholdValue());
model = blindBoxInfoModels.get(i);
}
}
long userID = IMLoginManager.get(mContext).getUserInfo().getId();
String boxBlindName;
//判断送礼用户更新送礼用户进度
if (TextUtils.equals(String.valueOf(userID), event.getUid()) && blindBoxType == Integer.parseInt(event.getBoxType())) {
switch (blindBoxType) {
case 1:
boxBlindName = mContext.getString(R.string.mini_blind_box);
progressBlind.setMax(Integer.parseInt(model.getThresholdValue()));
progressBlind.setProgress(Integer.parseInt(model.getDressThresholdValue()));
break;
case 2:
boxBlindName = mContext.getString(R.string.collection_blind_box);
progressBlind1.setMax(Integer.parseInt(model.getThresholdValue()));
progressBlind1.setProgress(Integer.parseInt(model.getDressThresholdValue()));
break;
default:
boxBlindName = mContext.getString(R.string.pd_blind_box);
progressBlind2.setMax(Integer.parseInt(model.getThresholdValue()));
progressBlind2.setProgress(Integer.parseInt(model.getDressThresholdValue()));
break;
}
//进度下方提示语
if (TextUtils.equals(model.getThresholdValue(), model.getDressThresholdValue())) {
String individualDressing = mContext.getString(R.string.individual_dressing);
String msg = mContext.getString(R.string.have_already_win);
msg = String.format(msg, model.getThresholdDressName());
int dressNameIndexOf = msg.indexOf(model.getThresholdDressName());
int individualDressingIndexOf = msg.indexOf(String.valueOf(individualDressing));
int dressNameSize = model.getThresholdDressName().length();
int individualDressingSize = String.valueOf(individualDressing).length();
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(msg);
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFF682")), dressNameIndexOf, dressNameIndexOf + dressNameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFF682")), individualDressingIndexOf, individualDressingIndexOf + individualDressingSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
blindNumber.setText(builder);
} else {
int progress = Integer.parseInt(model.getThresholdValue()) - Integer.parseInt(model.getDressThresholdValue());
String msg = mContext.getString(R.string.resend_win);
msg = String.format(msg, String.valueOf(progress), boxBlindName, model.getThresholdDressName());
int dressNameIndexOf = msg.indexOf(model.getThresholdDressName());
int progressIndexOf = msg.indexOf(String.valueOf(progress));
int dressNameSize = model.getThresholdDressName().length();
int progressSize = String.valueOf(progress).length();
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(msg);
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFF682")), dressNameIndexOf, dressNameIndexOf + dressNameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFF682")), progressIndexOf, progressIndexOf + progressSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
blindNumber.setText(builder);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(model.getDressThresholdValue())
.append("/")
.append(model.getThresholdValue());
textBlindProgress.setText(stringBuffer.toString());
}
}
}
}

View File

@ -334,7 +334,7 @@ public class SocketClient {
receiveGiftBean.setUid(uid);
receiveGiftBean.setGuardType(map.getString("guard_type"));
receiveGiftBean.setSendtype(map.getIntValue("action"));
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean,null);
}
} else {
LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
@ -346,7 +346,7 @@ public class SocketClient {
receiveGiftBean.setUid(map.getString("uid"));
receiveGiftBean.setGuardType(map.getString("guard_type"));
receiveGiftBean.setSendtype(map.getIntValue("action"));
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean,null);
}
}
@ -557,13 +557,13 @@ public class SocketClient {
LivePKUserListBean livePKUserListBean = JSON.parseObject(receiveGiftBean.getPkTopUsers(), LivePKUserListBean.class);
if (mLiveUid.equals(map.getString("roomnum"))) {
if (!mLiveUid.equals(map.getString("roomnum"))) {
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean,null);
}
//同一个直播间时才刷新pk
mListener.onSendGiftPk(map.getLongValue("pktotal1"), map.getLongValue("pktotal2"), livePKUserListBean);
} else {
if (!mLiveUid.equals(map.getString("roomnum"))) {
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean,null);
}
//同一个直播间时才刷新pk
if (mLiveUid.equals(map.getString("pkuid1")) ||
@ -574,7 +574,7 @@ public class SocketClient {
}
} else {
if (!mLiveUid.equals(map.getString("roomnum"))) {
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean,null);
}
}
}
@ -628,7 +628,7 @@ public class SocketClient {
try {
if (!TextUtils.isEmpty(mLiveUid)) {
if (mLiveUid.equals(map.getString("roomnum"))) {
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean,null);
mListener.onSendGiftPk(map.getLongValue("pktotal1"), map.getLongValue("pktotal2"), livePKUserListBean);
} else {
mListener.onSendGiftPk(map.getLongValue("pktotal2"), map.getLongValue("pktotal1"), livePKUserListBean);
@ -640,7 +640,7 @@ public class SocketClient {
} else {
Log.i("tvvs", receiveGiftBean.getLiveChatBean().getContent());
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean,null);
}
if (map.getIntValue("drpk_status") == 1) {
LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, 0);

View File

@ -2,6 +2,7 @@ package com.yunbao.live.socket;
import com.alibaba.fastjson.JSONObject;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.SendBlindGiftEvent;
import com.yunbao.live.bean.LiveBuyGuardMsgBean;
import com.yunbao.live.bean.LiveChatBean;
import com.yunbao.live.bean.LiveDanMuBean;
@ -57,7 +58,7 @@ public interface SocketMessageListener {
*
* @param bean 礼物信息
*/
void onSendGift(LiveReceiveGiftBean bean);
void onSendGift(LiveReceiveGiftBean bean, SendBlindGiftEvent event);
void onBuyZuoji(LiveReceiveGiftBean bean);

View File

@ -33,6 +33,7 @@ import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.WishModel;
import com.yunbao.common.bean.XydCompleteModel;
import com.yunbao.common.event.CustomFullServiceNotifyEvent;
import com.yunbao.common.event.SendBlindGiftEvent;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.IMRTCManager;
@ -680,7 +681,7 @@ public class SocketRyClient {
receiveGiftBean.setUid(uid);
receiveGiftBean.setGuardType(map.getString("guard_type"));
receiveGiftBean.setSendtype(map.getIntValue("action"));
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean, null);
}
} else {
LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
@ -692,7 +693,7 @@ public class SocketRyClient {
receiveGiftBean.setUid(map.getString("uid"));
receiveGiftBean.setGuardType(map.getString("guard_type"));
receiveGiftBean.setSendtype(map.getIntValue("action"));
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean, null);
}
}
@ -907,13 +908,13 @@ public class SocketRyClient {
LivePKUserListBean livePKUserListBean = JSON.parseObject(receiveGiftBean.getPkTopUsers(), LivePKUserListBean.class);
if (mLiveUid.equals(map.getString("roomnum"))) {
if (!mLiveUid.equals(map.getString("roomnum"))) {
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean, null);
}
//同一个直播间时才刷新pk
mListener.onSendGiftPk(map.getLongValue("pktotal1"), map.getLongValue("pktotal2"), livePKUserListBean);
} else {
if (!mLiveUid.equals(map.getString("roomnum"))) {
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean, null);
}
//同一个直播间时才刷新pk
if (mLiveUid.equals(map.getString("pkuid1")) ||
@ -924,7 +925,7 @@ public class SocketRyClient {
}
} else {
if (!mLiveUid.equals(map.getString("roomnum"))) {
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean, null);
}
}
}
@ -963,12 +964,15 @@ public class SocketRyClient {
chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + " " + +receiveGiftBean.getGiftCount() + " " + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftnameen());
}
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean, null);
}
// 玩家自己送礼物
private void sendGiftInSameRoom(JSONObject map) {
String ctJson = map.getString("ct");
SendBlindGiftEvent sendBlindGiftEvent = GsonUtils.fromJson(ctJson, SendBlindGiftEvent.class);
LiveReceiveGiftBean receiveGiftBean = JSON.parseObject(map.getString("ct"), LiveReceiveGiftBean.class);
sendBlindGiftEvent.setUserNiceName(map.getString("uname"));
receiveGiftBean.setAvatar(map.getString("uhead") + "");
receiveGiftBean.setUserNiceName(map.getString("uname"));
receiveGiftBean.setRoomnum(map.getString("roomnum"));
@ -997,11 +1001,11 @@ public class SocketRyClient {
if (map.get("guard_type") != null && !"".equals(map.get("guard_type")) && !"null".equals(map.get("guard_type"))) {
chatBean.setGuardType(map.getInteger("guard_type"));
}
if (CommonAppContext.lang.equals("chinese")) {
chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + receiveGiftBean.getGiftCount() + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftName());
} else {
chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + " " + +receiveGiftBean.getGiftCount() + " " + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftnameen());
}
//增加粉丝徽章信息
chatBean.setMedalNmae(map.getString("medal_name"));
@ -1010,12 +1014,12 @@ public class SocketRyClient {
chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
receiveGiftBean.setLiveChatBean(chatBean);
Log.e("tag", "ifpk" + map.getIntValue("ifpk") + "");
if (map.getIntValue("ifpk") == 1) {
try {
if (!TextUtils.isEmpty(mLiveUid)) {
if (mLiveUid.equals(map.getString("roomnum"))) {
mListener.onSendGift(receiveGiftBean);
mListener.onSendGift(receiveGiftBean, null);
mListener.onSendGiftPk(map.getLongValue("pktotal1"), map.getLongValue("pktotal2"), livePKUserListBean);
} else {
mListener.onSendGiftPk(map.getLongValue("pktotal2"), map.getLongValue("pktotal1"), livePKUserListBean);
@ -1027,7 +1031,12 @@ public class SocketRyClient {
} else {
Log.i("tvvs", receiveGiftBean.getLiveChatBean().getContent());
mListener.onSendGift(receiveGiftBean);
if (!TextUtils.isEmpty(sendBlindGiftEvent.getAction()) && TextUtils.equals("blind_box", sendBlindGiftEvent.getAction())) {
mListener.onSendGift(receiveGiftBean, sendBlindGiftEvent);
} else {
mListener.onSendGift(receiveGiftBean, null);
}
}
if (map.getIntValue("drpk_status") == 1) {
Bus.get().post(new LiveAudienceEvent()

View File

@ -86,6 +86,19 @@ public class LiveTextRender {
sFontSizeSpan3 = new AbsoluteSizeSpan(14, true);
}
public void blindBox(Context context, TextView textView, LiveChatBean bean) {
String chatMsg = bean.getContent();
int userNiceNameIndex = chatMsg.indexOf(bean.getUserNiceName());
int userNiceNameSize = bean.getUserNiceName().length();
int giftNameIndex = chatMsg.indexOf(bean.getGiftName());
int giftNameSize = bean.getGiftName().length();
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(chatMsg);
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#78FEFF")), userNiceNameIndex, userNiceNameIndex + userNiceNameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFF86C")), giftNameIndex, giftNameIndex + giftNameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(builder);
}
/**
* 直播间推荐卡
*

View File

@ -45,6 +45,7 @@ import com.yunbao.common.bean.XydCompleteModel;
import com.yunbao.common.custom.MyViewPager;
import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.event.LiveFloatEvent;
import com.yunbao.common.event.SendBlindGiftEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
@ -269,7 +270,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void run() {
try{
try {
Log.e("ImgLoader1", data.getAvatar());
if (mLiveRyLinkMicPkPresenter != null) {
@ -367,7 +368,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
enterRoomNew();
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
@ -1119,7 +1120,34 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
@Override
public void onSendGift(LiveReceiveGiftBean bean) {
public void onSendGift(LiveReceiveGiftBean bean, SendBlindGiftEvent event) {
if (event != null) {
LiveChatBean liveChatBean = null;
if (!TextUtils.isEmpty(event.getDressName()) && !TextUtils.isEmpty(event.getDressMsg())) {
liveChatBean = new LiveChatBean();
liveChatBean.setUserNiceName(event.getUserNiceName());
liveChatBean.setType(LiveChatBean.BLIND_BOX);
liveChatBean.setGiftName(event.getDressName());
liveChatBean.setContent(event.getDressMsg());
}
//插入盲盒礼物消息
bean.getLiveChatBean().setType(LiveChatBean.BLIND_BOX);
bean.getLiveChatBean().setContent(event.getGiftMsg());
bean.getLiveChatBean().setGiftName(event.getGiftname());
bean.getLiveChatBean().setUserNiceName(event.getUserNiceName());
if (mLiveRoomViewHolder != null) {
if (bean.getmLiveUId().equals(bean.getRoomnum())) {
if (liveChatBean != null) {
mLiveRoomViewHolder.insertChat(liveChatBean, 1);
}
mLiveRoomViewHolder.insertChat(bean.getLiveChatBean(), 1);
}
mLiveRoomViewHolder.showGiftMessage(bean, false);
mLiveRoomViewHolder.updataWishList(bean.getGiftId(), bean.getGiftCount());
}
Bus.get().post(event);
} else {
//购买守护
if (bean.ismTypeBuyGuard()) {
if (mLiveRoomViewHolder != null) {
@ -1134,6 +1162,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.showGiftMessage(bean, false);
mLiveRoomViewHolder.updataWishList(bean.getGiftId(), bean.getGiftCount());
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -41,21 +41,20 @@
<LinearLayout
android:id="@+id/btn_luck_gift_tip"
android:layout_width="105.27dp"
android:layout_height="32dp"
android:layout_width="102dp"
android:layout_height="31dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="12dp"
android:background="@drawable/bg_live_vip_blue"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/vipGoldIcon"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginEnd="7dp"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_marginEnd="3.5dp"
android:scaleType="centerCrop"
android:src="@mipmap/icon_vip_gold" />
android:src="@mipmap/icon_vip_gold_new" />
<LinearLayout
android:layout_width="wrap_content"
@ -69,8 +68,9 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:text="@string/live_gift_buy_gold"
android:textColor="#FFFFFF"
android:textSize="11.52sp" />
android:textStyle="bold"
android:textColor="#F5C600"
android:textSize="10sp" />
<TextView
android:id="@+id/vipGoldDesc"
@ -78,8 +78,8 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="@string/live_gift_buy_gold_desc"
android:textColor="#999999"
android:textSize="7.68sp" />
android:textColor="#FFFFFF"
android:textSize="8sp" />
</LinearLayout>
</LinearLayout>

View File

@ -11,12 +11,13 @@
android:layout_height="86.5dp"
android:background="@mipmap/bg_phoenix">
<com.yunbao.common.views.weight.ClipPathCircleImage
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/blind_svga"
android:layout_width="29dp"
android:layout_height="29dp"
android:layout_marginStart="14dp"
android:layout_marginTop="51dp"
android:src="@mipmap/icon_avatar_test" />
/>
<LinearLayout
android:layout_width="wrap_content"

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -287,6 +287,7 @@ public class LoginActivity extends AbsActivity {
getBaseUserInfo();
} else {
ToastUtil.show(msg);
loadingDialog.dismiss();
}
}