盲盒全服通知逻辑

This commit is contained in:
18401019693
2023-05-27 11:40:09 +08:00
parent b4dc035a1b
commit 66290323d8
41 changed files with 720 additions and 109 deletions

View File

@@ -81,7 +81,6 @@ import com.yunbao.common.utils.ProcessResultUtil;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.CustomDrawerPopupView;
import com.yunbao.common.views.floatingview.APPEasyFloat;
import com.yunbao.common.views.weight.VerticalViewPager;
@@ -861,10 +860,10 @@ public class LiveAudienceActivity extends LiveActivity {
public void showerHtml(String htmlUrl, boolean screen) {
if (TextUtils.equals(htmlUrl, "recharge")) {
RouteUtil.forwardMyCoin(mContext);
} else if (TextUtils.equals(htmlUrl, "to_me_information")){
onBackPressed();
} else if (TextUtils.equals(htmlUrl, "to_me_information")) {
onBackPressed();
Constants.isShowPage = 3;
}else {
} else {
if (!screen) {
ZhuangBanActivity.forward(mContext, htmlUrl, false);
} else {
@@ -1377,7 +1376,11 @@ public class LiveAudienceActivity extends LiveActivity {
} catch (Exception e) {
e.printStackTrace();
}
break;
case BLIND_BOX:
if (manager != null) {
manager.blindBoxAllServerNotify(event.getAllServerNotifyEvent());
}
break;
}

View File

@@ -3,13 +3,15 @@ package com.yunbao.live.bean;
import android.text.TextUtils;
import com.alibaba.fastjson.annotation.JSONField;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.event.AllServerNotifyEvent;
/**
* Created by cxf on 2017/8/22.
* 收到送礼物消息的实体类
*/
public class LiveReceiveGiftBean {
public class LiveReceiveGiftBean extends BaseModel {
private String uid;
private String avatar;
@@ -51,6 +53,26 @@ public class LiveReceiveGiftBean {
private String nobilityname;
private String opentype;
private String anchorUid;
private boolean isBlindBox = false;
private AllServerNotifyEvent event = new AllServerNotifyEvent();
public AllServerNotifyEvent getEvent() {
return event;
}
public LiveReceiveGiftBean setEvent(AllServerNotifyEvent event) {
this.event = event;
return this;
}
public boolean isBlindBox() {
return isBlindBox;
}
public LiveReceiveGiftBean setBlindBox(boolean blindBox) {
isBlindBox = blindBox;
return this;
}
public String getAnchorUid() {
return anchorUid;

View File

@@ -170,7 +170,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
window.setDimAmount(0f);//去掉遮罩层(全透明)
WindowManager.LayoutParams params = window.getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = DpUtil.dp2px(355);
params.height = DpUtil.dp2px(433);
params.gravity = Gravity.BOTTOM;
window.setAttributes(params);
}
@@ -698,6 +698,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
}
private void itemCheckOp(LiveGiftBean bean) {
stringBuilders.clear();
mLiveGiftBean = bean;
hideLianBtn();
mBtnSend.setEnabled(true);
@@ -715,13 +716,12 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
showBlindProgress(bean.getBlind_box_type());
} else {
mVipGold.setVisibility(View.VISIBLE);
blindBox.setVisibility(View.GONE);
WindowManager.LayoutParams params = getDialog().getWindow().getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = DpUtil.dp2px(355);
params.gravity = Gravity.BOTTOM;
getDialog().getWindow().setAttributes(params);
if (isPk) {
mVipGold.setVisibility(View.GONE);
}else {
mVipGold.setVisibility(View.VISIBLE);
}
blindBox.setVisibility(View.INVISIBLE);
}
}
@@ -761,11 +761,6 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
mBtnChooseCount.setEnabled(false);
mVipGold.setVisibility(View.GONE);
blindBox.setVisibility(View.VISIBLE);
WindowManager.LayoutParams params = getDialog().getWindow().getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = DpUtil.dp2px(433);
params.gravity = Gravity.BOTTOM;
getDialog().getWindow().setAttributes(params);
String boxBlindName = "";
switch (blindBoxType) {
case 1:
@@ -818,7 +813,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
} 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());
msg = String.format(msg, String.valueOf(progress), model.getThresholdDressName());
int dressNameIndexOf = msg.indexOf(model.getThresholdDressName());
int progressIndexOf = msg.indexOf(String.valueOf(progress));
int dressNameSize = model.getThresholdDressName().length();
@@ -1050,6 +1045,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
for (int i = 0; i < blindBoxInfoModels.size(); i++) {
if (TextUtils.equals(blindBoxInfoModels.get(i).getBlindBoxType(), event.getBoxType())) {
blindBoxInfoModels.get(i).setDressThresholdValue(event.getDressThresholdValue());
blindBoxInfoModels.get(i).setThresholdValue(event.getThresholdValue());
model = blindBoxInfoModels.get(i);
}
}
@@ -1091,10 +1087,11 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
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);
textBlindProgress.setText(R.string.get_it_done);
} 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());
msg = String.format(msg, String.valueOf(progress), model.getThresholdDressName());
int dressNameIndexOf = msg.indexOf(model.getThresholdDressName());
int progressIndexOf = msg.indexOf(String.valueOf(progress));
int dressNameSize = model.getThresholdDressName().length();
@@ -1110,6 +1107,58 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
.append(model.getThresholdValue());
textBlindProgress.setText(stringBuffer.toString());
}
if (stringBuilders.size() == 0) {
boxBlindHandler.postDelayed(boxBlindRunnable, 1500);
}
if (!TextUtils.isEmpty(event.getDressName()) && !TextUtils.isEmpty(event.getDressMsg())) {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
String boxBlindMsg = String.format(mContext.getString(R.string.random_availability2), event.getGiftname(), event.getDressName());
stringBuilder.append(boxBlindMsg);
int dressNameIndex = boxBlindMsg.indexOf(event.getDressName());
int dressNameSize = event.getDressName().length();
int giftNameIndex = boxBlindMsg.indexOf(event.getGiftname());
int giftNameSize = event.getGiftname().length();
stringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor(event.getDressColour())),
dressNameIndex,
dressNameIndex + dressNameSize,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
stringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor(event.getGiftColour())),
giftNameIndex,
giftNameIndex + giftNameSize,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
stringBuilders.add(stringBuilder);
} else {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
String boxBlindMsg = String.format(mContext.getString(R.string.random_availability3), event.getGiftname());
stringBuilder.append(boxBlindMsg);
int giftNameIndex = boxBlindMsg.indexOf(event.getGiftname());
int giftNameSize = event.getGiftname().length();
stringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor(event.getGiftColour())),
giftNameIndex,
giftNameIndex + giftNameSize,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
stringBuilders.add(stringBuilder);
}
}
}
private List<SpannableStringBuilder> stringBuilders = new ArrayList<>();
private Handler boxBlindHandler = new Handler();
private Runnable boxBlindRunnable = new Runnable() {
@Override
public void run() {
if (stringBuilders != null && stringBuilders.size() > 0) {
SpannableStringBuilder stringBuilder = stringBuilders.get(0);
textBlindGiftName.setText(stringBuilder);
boxBlindHandler.postDelayed(boxBlindRunnable, 1100);
stringBuilders.remove(0);
} else {
textBlindGiftName.setText(String.format(mContext.getString(R.string.random_availability), blindGiftNamesBuffer.toString()));
}
}
};
}

View File

@@ -9,6 +9,7 @@ import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.WishModel;
import com.yunbao.common.bean.XydCompleteModel;
import com.yunbao.common.event.AllServerNotifyEvent;
import com.yunbao.common.event.CustomFullServiceNotifyEvent;
import com.yunbao.live.bean.LivePKUserListBean;
import com.yunbao.live.bean.LiveReceiveGiftBean;
@@ -41,6 +42,16 @@ public class LiveAudienceEvent extends BaseModel {
private WishModel wishListProgress;
private XydCompleteModel xydCompleteModel;
private LiveReceiveGiftBean liveReceiveGiftBean;
private AllServerNotifyEvent allServerNotifyEvent;
public AllServerNotifyEvent getAllServerNotifyEvent() {
return allServerNotifyEvent;
}
public LiveAudienceEvent setAllServerNotifyEvent(AllServerNotifyEvent allServerNotifyEvent) {
this.allServerNotifyEvent = allServerNotifyEvent;
return this;
}
public LiveReceiveGiftBean getLiveReceiveGiftBean() {
return liveReceiveGiftBean;
@@ -344,7 +355,8 @@ public class LiveAudienceEvent extends BaseModel {
LIVE_FONT_SIZE(64, "字号设置"),
VOTE_CREATE(65, "创建投票"),
VOTE_UPDATE(66, "更新投票"),
VOTE_END(67, "投票结束");
VOTE_END(67, "投票结束"),
BLIND_BOX(68, "盲盒全服通知");
private int type;
private String name;

View File

@@ -6,6 +6,7 @@ import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
@@ -23,6 +24,7 @@ import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.MediaController;
import android.widget.TextView;
@@ -37,6 +39,7 @@ import com.yunbao.common.Constants;
import com.yunbao.common.HtmlConfig;
import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.event.AllServerNotifyEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
@@ -48,14 +51,14 @@ import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.HtmlTagHandler;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.bean.LiveGiftPrizePoolWinBean;
import com.yunbao.live.bean.LiveLuckGiftWinBean;
import com.yunbao.live.bean.LiveReceiveGiftBean;
import com.yunbao.live.custom.FrameImageView;
import com.yunbao.live.dialog.LiveGiftDialogFragment;
import com.yunbao.live.event.LiveRoomChangeEvent;
import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.utils.AllMsgTextRender;
@@ -86,7 +89,9 @@ import pl.droidsonroids.gif.GifImageView;
public class LiveGiftAnimPresenter {
private final View mIvLook;
private final TextView mIvLook;
private View superNotice;
private LinearLayout bgAllServer;
private final View mGifGiftTipGroupBuyGuard;
private final View mIvLookBuyGuard;
private final View mGifGiftTipGroupBuyZuoji;
@@ -162,6 +167,8 @@ public class LiveGiftAnimPresenter {
private boolean mShowBuyLiangName;
private boolean mShowBuyVip;
private boolean mShowBlindBox;
private CommonCallback<File> mDownloadGifCallback;
private CommonCallback<File> mDownloadIconCallback;
@@ -216,6 +223,8 @@ public class LiveGiftAnimPresenter {
mTitleContainer = v.findViewById(R.id.title_container);
mSVGAImageViewFront = v.findViewById(R.id.svga_iv_all_server);
mIvLook = v.findViewById(R.id.iv_look);
superNotice = v.findViewById(R.id.super_notice);
bgAllServer = v.findViewById(R.id.bg_all_server);
mIvLookBuyGuard = v.findViewById(R.id.iv_look_buy_guard);
svgaImageViewCallback();
@@ -325,7 +334,25 @@ public class LiveGiftAnimPresenter {
@Override
public void onClick(View view) {
//切换直播间
changeLiveRoom();
if (TextUtils.equals(mIvLook.getText().toString(),mContext.getString(R.string.participate_in))) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
LiveGiftDialogFragment fragment = new LiveGiftDialogFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.LIVE_UID, mLiveUid);
bundle.putString(Constants.LIVE_STREAM, mStream);
bundle.putString(Constants.LIVE_WISH_GIFTID, blindBox.getEvent().getBlindBoxId() + "");
bundle.putBoolean("isContactGift", true);
fragment.setArguments(bundle);
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
}
}, 1000);
} else {
changeLiveRoom();
}
}
});
mGifGiftTipGroupAllServer.setOnClickListener(new View.OnClickListener() {
@@ -336,6 +363,14 @@ public class LiveGiftAnimPresenter {
});
}
public String mLiveUid;
public String mStream;
public void setLiveUidStream(String liveUid, String stream) {
mLiveUid = liveUid;
mStream = stream;
}
private void mIvLookBuyZuojiClick() {
mGifGiftTipGroupBuyZuoji.setOnClickListener(new View.OnClickListener() {
@Override
@@ -410,7 +445,7 @@ public class LiveGiftAnimPresenter {
private void setGitTipAnimatorAllServer() {
mDp500 = DpUtil.dp2px(500);
mGifGiftTipShowAnimatorAllServer = ObjectAnimator.ofFloat(mGifGiftTipGroupAllServer, "translationX", mDp500, 0);
mGifGiftTipShowAnimatorAllServer.setDuration(2000);
mGifGiftTipShowAnimatorAllServer.setDuration(2500);
mGifGiftTipShowAnimatorAllServer.setInterpolator(new LinearInterpolator());
mGifGiftTipShowAnimatorAllServer.addListener(new AnimatorListenerAdapter() {
@Override
@@ -422,7 +457,7 @@ public class LiveGiftAnimPresenter {
});
mDp10 = DpUtil.dp2px(10);
mGifGiftTipHideAnimatorAllServer = ObjectAnimator.ofFloat(mGifGiftTipGroupAllServer, "translationX", 0);
mGifGiftTipHideAnimatorAllServer.setDuration(3000);
mGifGiftTipHideAnimatorAllServer.setDuration(3500);
mGifGiftTipHideAnimatorAllServer.setInterpolator(new AccelerateDecelerateInterpolator());
mGifGiftTipHideAnimatorAllServer.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
@@ -673,10 +708,16 @@ public class LiveGiftAnimPresenter {
mGifGiftTipHideAnimatorAllServer.start();
} else if (msg.what == WHAT_ALL_SERVER_2) {
mShowAllServer = false;
mShowBlindBox = false;
heightOffsetArr[index4OtherGift] = 0;
LiveReceiveGiftBean bean = mGifAll.poll();
if (bean != null) {
chooseInto(bean);
if (bean.isBlindBox()) {
showSendGiftAnimAllServer2(bean);
} else {
chooseInto(bean);
}
}
} else if (msg.what == WHAT_BUY_GUARD_1) {
mGifGiftTipHideAnimatorBuyGuard.setFloatValues(0, -mDp10 - mGifGiftTipGroupBuyGuard.getWidth());
@@ -832,8 +873,6 @@ public class LiveGiftAnimPresenter {
}
} else {
mShowAllServer = true;
index4OtherGift = getFirstIndexOfValue(heightOffsetArr, 0);
if (index4OtherGift >= 0) {
heightOffsetArr[index4OtherGift] = 1;
@@ -843,16 +882,57 @@ public class LiveGiftAnimPresenter {
params.topMargin = DpUtil.dp2px(y);
mGifGiftTipGroupAllServer.setLayoutParams(params);
}
mAncherName = mTempGifGiftBean.getAncherName();
mGifGiftTipAllServer.setSelected(false);
mIvLook.setVisibility(View.VISIBLE);
mGifGiftTipGroupAllServer.setAlpha(1f);
mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE);
textRender.render(mContext, mGifGiftTipAllServer, mTempGifGiftBean.getGiftIcon(), mTempGifGiftBean.getUserNiceName(), mAncherName, mTempGifGiftBean.getGiftName(), 1, mWindowManager, "");
mIvLook.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimatorAllServer.start();
textRender.render(mContext, mGifGiftTipAllServer, mTempGifGiftBean.getGiftIcon(), mTempGifGiftBean.getUserNiceName(), mAncherName, mTempGifGiftBean.getGiftName(), 1, mWindowManager, "");
}
} //送礼物 全服通知
private LiveReceiveGiftBean blindBox = null;
public void showSendGiftAnimAllServer2(LiveReceiveGiftBean bean) {
blindBox = bean;
if (mShowBlindBox) {
if (mGifAll != null) {
mGifAll.offer(bean);
}
} else {
mShowBlindBox = true;
mAncherName = bean.getAncherName();
mGifGiftTipAllServer.setSelected(false);
mGifGiftTipGroupAllServer.setAlpha(1f);
mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE);
AllServerNotifyEvent serverNotifyEvent = bean.getEvent();
switch (Integer.parseInt(serverNotifyEvent.getBoxType())) {
case 1:
bgAllServer.setBackgroundResource(R.mipmap.bg_kirin_notify);
mIvLook.setBackgroundResource(R.drawable.bg_all_server_336cf7);
break;
case 2:
bgAllServer.setBackgroundResource(R.mipmap.bg_phoenix_notify);
mIvLook.setBackgroundResource(R.drawable.bg_all_server_fd5a9d);
break;
default:
bgAllServer.setBackgroundResource(R.mipmap.bg_dragon_notify);
mIvLook.setBackgroundResource(R.drawable.bg_all_server_fcb50e);
break;
}
mIvLook.setText(R.string.participate_in);
superNotice.setBackgroundResource(R.mipmap.icon_blind_box_headlines);
mIvLook.setVisibility(View.VISIBLE);
textRender.blindBoxText(mContext, mGifGiftTipAllServer, serverNotifyEvent);
mGifGiftTipShowAnimatorAllServer.start();
mGifGiftTipAllServer.postDelayed(() -> {
if (mGifGiftTipAllServer != null) {
mGifGiftTipAllServer.setSelected(true);
}
}, delayMarqueen + 600);
}
}
@@ -934,7 +1014,7 @@ public class LiveGiftAnimPresenter {
}
String text = mTempGifGiftBean.getUserNiceName() + " <myfont size='24px'>"
+mContext.getString(R.string.live_send_buy_zuoji_1)
+ mContext.getString(R.string.live_send_buy_zuoji_1)
+ "</myfont> " + (mTempGifGiftBean.getCarName());
Spanned spanned = Html.fromHtml(text, null, new HtmlTagHandler("myfont"));
mGifGiftTipBuyZuoji.setText(spanned);
@@ -975,7 +1055,7 @@ public class LiveGiftAnimPresenter {
}
String text = mTempGifGiftBean.getUserNiceName() + " <myfont size='24px'>"
+mContext.getString(R.string.live_send_buy_liang_name_1)
+ mContext.getString(R.string.live_send_buy_liang_name_1)
+ "</myfont> " + mTempGifGiftBean.getLiangName();
Spanned spanned = Html.fromHtml(text, null, new HtmlTagHandler("myfont"));
mGifGiftTipBuyLiangName.setText(spanned);
@@ -1124,7 +1204,7 @@ public class LiveGiftAnimPresenter {
}
});
} else {
GiftCacheUtil.getFile(mContext,Constants.GIF_GIFT_PREFIX + bean.getGiftId(), url, "1", mDownloadGifCallback);
GiftCacheUtil.getFile(mContext, Constants.GIF_GIFT_PREFIX + bean.getGiftId(), url, "1", mDownloadGifCallback);
}
}

View File

@@ -32,6 +32,7 @@ import com.yunbao.common.bean.SocketModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.WishModel;
import com.yunbao.common.bean.XydCompleteModel;
import com.yunbao.common.event.AllServerNotifyEvent;
import com.yunbao.common.event.CustomFullServiceNotifyEvent;
import com.yunbao.common.event.SendBlindGiftEvent;
import com.yunbao.common.http.HttpCallback;
@@ -363,6 +364,24 @@ public class SocketRyClient {
buyZuoJiByNotify(map);
} else if (action2 == 66) {//购买贵族
buyVipByNotify(map);
} else if (action2 == 88) {
AllServerNotifyEvent allServerNotifyEvent
= new AllServerNotifyEvent()
.setBlindBoxId(map.getString("blind_box_id"))
.setBoxType(map.getString("box_type"))
.setBoxTypeName(map.getString("box_type_name"))
.setDressName(map.getString("dress_name"))
.setGiftNotification(map.getString("gift_notification"))
.setGiftName(map.getString("giftname"))
.setUserNiceName(map.getString("uname"))
.setGiftIcon(map.getString("gifticon"))
.setAnchorName(map.getString("ancherName"))
.setDisplaySrc(map.getString("display_src"));
Log.e("AllServerNotifyEvent", allServerNotifyEvent.toString());
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX)
.setAllServerNotifyEvent(allServerNotifyEvent));
}
break;
case Constants.SOCKET_SEND_BARRAGE://发弹幕

View File

@@ -1,14 +1,18 @@
package com.yunbao.live.utils;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.view.WindowManager;
import android.widget.TextView;
import com.yunbao.common.custom.VerticalImageSpan;
import com.yunbao.common.event.AllServerNotifyEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.live.R;
@@ -68,7 +72,7 @@ public class AllMsgTextRender {
ImgLoader.displayDrawable(context, url, new ImgLoader.DrawableCallback() {
@Override
public void onLoadSuccess(Drawable drawable) {
if (builder!=null&&!builder.toString().contains(text)){
if (builder != null && !builder.toString().contains(text)) {
builder = createPrefix(drawable, builder);
builder = renderMsg(color2, builder, text);
textView.setText(builder);
@@ -124,6 +128,95 @@ public class AllMsgTextRender {
}
}
/**
* 盲盒字体组装
*
* @param context
* @param textView
* @param serverNotifyEvent
*/
public void blindBoxText(Context context, TextView textView, AllServerNotifyEvent serverNotifyEvent) {
String space = " ";
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
String extractTo = context.getString(R.string.extract_to);
extractTo = String.format(extractTo, serverNotifyEvent.getUserNiceName(), serverNotifyEvent.getBoxTypeName());
spannableStringBuilder.append(extractTo);
int indexImage = spannableStringBuilder.length();
int endImage = indexImage + space.length();
spannableStringBuilder.append(space);
String giftName;
int giftNameIndex;
int endName;
if (!TextUtils.isEmpty(serverNotifyEvent.getGiftNotification())
&& TextUtils.equals(serverNotifyEvent.getGiftNotification(), "1")) {
giftName = context.getString(R.string.extract_to2);
giftName = String.format(giftName, serverNotifyEvent.getGiftName(), serverNotifyEvent.getAnchorName());
spannableStringBuilder.append(giftName);
giftNameIndex = spannableStringBuilder.toString().indexOf(serverNotifyEvent.getGiftName());
endName = giftNameIndex + serverNotifyEvent.getGiftName().length();
ImgLoader.displayDrawable(context, serverNotifyEvent.getGiftIcon(), new ImgLoader.DrawableCallback() {
@Override
public void onLoadSuccess(Drawable drawable) {
drawable.setBounds(0, 0, DpUtil.dp2px(21), DpUtil.dp2px(21));
//用这个drawable对象代替字符串easy
ImageSpan span = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE);
spannableStringBuilder.setSpan(span, indexImage, endImage, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
blind(spannableStringBuilder,textView,serverNotifyEvent,giftNameIndex,endName);
}
@Override
public void onLoadFailed() {
blind(spannableStringBuilder,textView,serverNotifyEvent,giftNameIndex,endName);
}
});
} else {
giftName = serverNotifyEvent.getDressName();
spannableStringBuilder.append(giftName);
giftNameIndex = spannableStringBuilder.toString().indexOf(giftName);
endName = giftNameIndex + giftName.length();
ImgLoader.displayDrawable(context, serverNotifyEvent.getDisplaySrc(), new ImgLoader.DrawableCallback() {
@Override
public void onLoadSuccess(Drawable drawable) {
drawable.setBounds(0, 0, DpUtil.dp2px(21), DpUtil.dp2px(21));
//用这个drawable对象代替字符串easy
ImageSpan span = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE);
spannableStringBuilder.setSpan(span, indexImage, endImage, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
blind(spannableStringBuilder,textView,serverNotifyEvent,giftNameIndex,endName);
}
@Override
public void onLoadFailed() {
blind(spannableStringBuilder,textView,serverNotifyEvent,giftNameIndex,endName);
}
});
}
}
private void blind( SpannableStringBuilder spannableStringBuilder, TextView textView, AllServerNotifyEvent serverNotifyEvent, int giftNameIndex,int endName) {
switch (Integer.parseInt(serverNotifyEvent.getBoxType())) {
case 1:
spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#336DF7")),
giftNameIndex,
endName,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case 2:
spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#FD5A9D")),
giftNameIndex,
endName,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
default:
spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#FCB514")),
giftNameIndex,
endName,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
}
textView.setText(spannableStringBuilder);
}
/**
* 渲染消息
*/

View File

@@ -88,6 +88,7 @@ import com.yunbao.common.bean.TaskModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.WishModel;
import com.yunbao.common.bean.XydCompleteModel;
import com.yunbao.common.event.AllServerNotifyEvent;
import com.yunbao.common.event.AnchorInfoEvent;
import com.yunbao.common.event.CustomFullServiceNotifyEvent;
import com.yunbao.common.glide.ImgLoader;
@@ -5093,4 +5094,15 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
});
}
public void blindBoxAllServerNotify(AllServerNotifyEvent event) {
LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
receiveGiftBean.setBlindBox(true);
receiveGiftBean.setEvent(event);
if (mLiveGiftAnimPresenter == null) {
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
}
mLiveGiftAnimPresenter.showSendGiftAnimAllServer2(receiveGiftBean);
mLiveGiftAnimPresenter.setLiveUidStream(mLiveUid, mStream);
}
}

View File

@@ -43,6 +43,7 @@ import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.WishModel;
import com.yunbao.common.bean.XydCompleteModel;
import com.yunbao.common.custom.MyViewPager;
import com.yunbao.common.event.AllServerNotifyEvent;
import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.event.LiveFloatEvent;
import com.yunbao.common.event.SendBlindGiftEvent;
@@ -1999,4 +2000,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.showXydComplete(model, false, liveReceiveGiftBean);
}
}
public void blindBoxAllServerNotify(AllServerNotifyEvent event) {
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.blindBoxAllServerNotify(event);
}
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="13dp" />
<solid android:color="#336CF7" />
</shape>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="13dp" />
<solid android:color="#FCB50E" />
</shape>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="13dp" />
<solid android:color="#FD5A9D" />
</shape>

View File

@@ -8,7 +8,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<LinearLayout
@@ -44,6 +44,8 @@
android:layout_width="102dp"
android:layout_height="31dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="70dp"
android:layout_marginBottom="5dp"
android:background="@drawable/bg_live_vip_blue"
android:gravity="center"
android:orientation="horizontal">
@@ -68,9 +70,9 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:text="@string/live_gift_buy_gold"
android:textStyle="bold"
android:textColor="#F5C600"
android:textSize="10sp" />
android:textSize="10sp"
android:textStyle="bold" />
<TextView
android:id="@+id/vipGoldDesc"
@@ -89,7 +91,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:visibility="gone">
android:visibility="invisible">
<include

View File

@@ -9,15 +9,14 @@
android:id="@+id/frame_blind_top"
android:layout_width="match_parent"
android:layout_height="86.5dp"
android:background="@mipmap/bg_phoenix">
android:background="@mipmap/bg_kirin">
<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:layout_marginTop="51dp" />
<LinearLayout
android:layout_width="wrap_content"
@@ -33,8 +32,8 @@
<ProgressBar
android:id="@+id/progress_blind3"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="74dp"
android:layout_height="6dp"
android:layout_width="80dp"
android:layout_height="8dp"
android:layout_gravity="center"
android:max="100"
android:progress="30"
@@ -44,8 +43,8 @@
<ProgressBar
android:id="@+id/progress_blind1"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="74dp"
android:layout_height="6dp"
android:layout_width="80dp"
android:layout_height="8dp"
android:layout_gravity="center"
android:max="100"
android:progress="50"
@@ -55,8 +54,8 @@
<ProgressBar
android:id="@+id/progress_blind2"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="74dp"
android:layout_height="6dp"
android:layout_width="80dp"
android:layout_height="8dp"
android:layout_gravity="center"
android:max="100"
android:progress="50"
@@ -72,26 +71,28 @@
</FrameLayout>
<TextView
android:id="@+id/blind_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textColor="@color/white"
android:textSize="6sp" />
</LinearLayout>
<TextView
android:id="@+id/blind_number"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginStart="47dp"
android:layout_marginTop="71dp"
android:textColor="@color/white"
android:textSize="8sp" />
<ImageView
android:layout_width="13dp"
android:layout_height="13dp"
android:layout_gravity="end"
android:layout_marginTop="47dp"
android:layout_marginEnd="19dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="15dp"
android:src="@mipmap/icon_what" />
</FrameLayout>
<FrameLayout
android:layout_width="139dp"
android:layout_width="149dp"
android:layout_height="match_parent"
android:background="@mipmap/bg_blind_bottom">
@@ -100,15 +101,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="7dp"
android:layout_margin="5dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:textSize="7sp"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="@color/white" />
android:textColor="@color/white"
android:textSize="10sp" />
</FrameLayout>
</LinearLayout>

View File

@@ -970,6 +970,7 @@
android:visibility="invisible">
<LinearLayout
android:id="@+id/bg_all_server"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
@@ -978,8 +979,9 @@
android:background="@drawable/bg_live_gift_tip"
android:gravity="center|left"
android:orientation="horizontal">
<!--盲盒头条-->
<View
android:id="@+id/super_notice"
android:layout_width="63dp"
android:layout_height="18sp"
android:layout_marginLeft="18dp"

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 KiB

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 KiB

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 74 KiB