红包全服通知
This commit is contained in:
@@ -913,24 +913,32 @@ public class LiveGiftAnimPresenter {
|
||||
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;
|
||||
if (serverNotifyEvent.isRedPacket()) {
|
||||
mIvLook.setVisibility(View.GONE);
|
||||
bgAllServer.setBackgroundResource(R.mipmap.backdrop_luck);
|
||||
superNotice.setBackgroundResource(R.mipmap.icon_luck);
|
||||
textRender.redPacket(mContext, mGifGiftTipAllServer, serverNotifyEvent);
|
||||
} else {
|
||||
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);
|
||||
mIvLook.setVisibility(View.VISIBLE);
|
||||
superNotice.setBackgroundResource(R.mipmap.icon_blind_box_headlines);
|
||||
textRender.blindBoxText(mContext, mGifGiftTipAllServer, serverNotifyEvent);
|
||||
}
|
||||
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) {
|
||||
|
||||
@@ -384,6 +384,17 @@ public class SocketRyClient {
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX)
|
||||
.setAllServerNotifyEvent(allServerNotifyEvent));
|
||||
} else if (action2 == 89) {//红包
|
||||
JSONObject mCt = map.getJSONObject("ct");
|
||||
AllServerNotifyEvent allServerNotifyEvent
|
||||
= new AllServerNotifyEvent()
|
||||
.setUserNiceName(mCt.getString("user_nicename"))
|
||||
.setGiftName(mCt.getString("giftname"))
|
||||
.setGiftIcon(mCt.getString("gifticon"))
|
||||
.setRedPacket(true);
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX)
|
||||
.setAllServerNotifyEvent(allServerNotifyEvent));
|
||||
}
|
||||
break;
|
||||
case Constants.SOCKET_SEND_BARRAGE://发弹幕
|
||||
@@ -834,7 +845,7 @@ public class SocketRyClient {
|
||||
chatBean.setContentColor(map.getString("contentColor"));//文字内容颜色
|
||||
chatBean.setAtUserName(map.getString("atUserName"));//@名字
|
||||
chatBean.setAtUserID(map.getString("atUserID"));//@ID
|
||||
if (map.containsKey("guard_type")&&!map.getString("guard_type").equals("undefined")) {
|
||||
if (map.containsKey("guard_type") && !map.getString("guard_type").equals("undefined")) {
|
||||
chatBean.setGuardType(map.getIntValue("guard_type"));
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -15,6 +15,7 @@ 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.common.views.CenterImageSpan;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.presenter.LiveGiftAnimPresenter;
|
||||
|
||||
@@ -128,6 +129,46 @@ public class AllMsgTextRender {
|
||||
}
|
||||
}
|
||||
|
||||
public void redPacket(Context context, TextView textView, AllServerNotifyEvent serverNotifyEvent) {
|
||||
String space = " ";
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
|
||||
String extractTo = context.getString(R.string.lucky_red_envelope);
|
||||
extractTo = String.format(extractTo, serverNotifyEvent.getUserNiceName(), serverNotifyEvent.getGiftName());
|
||||
spannableStringBuilder.append(extractTo);
|
||||
int indexImage = spannableStringBuilder.length();
|
||||
int endImage = indexImage + space.length();
|
||||
spannableStringBuilder.append(space);
|
||||
|
||||
int giftNameIndex = spannableStringBuilder.toString().indexOf(serverNotifyEvent.getGiftName());
|
||||
int endName = giftNameIndex + serverNotifyEvent.getGiftName().length();
|
||||
ImgLoader.displayDrawable(context, serverNotifyEvent.getGiftIcon(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
|
||||
|
||||
spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#FBC870")),
|
||||
giftNameIndex,
|
||||
endName,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
drawable.setBounds(0, 0, DpUtil.dp2px(25), DpUtil.dp2px(25));
|
||||
//用这个drawable对象代替字符串easy
|
||||
CenterImageSpan span = new CenterImageSpan(drawable);
|
||||
spannableStringBuilder.setSpan(span, indexImage, endImage, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
textView.setText(spannableStringBuilder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#FBC870")),
|
||||
giftNameIndex,
|
||||
endName,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
textView.setText(spannableStringBuilder);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 盲盒字体组装
|
||||
*
|
||||
@@ -161,12 +202,12 @@ public class AllMsgTextRender {
|
||||
//用这个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);
|
||||
blind(spannableStringBuilder, textView, serverNotifyEvent, giftNameIndex, endName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
blind(spannableStringBuilder,textView,serverNotifyEvent,giftNameIndex,endName);
|
||||
blind(spannableStringBuilder, textView, serverNotifyEvent, giftNameIndex, endName);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -181,19 +222,19 @@ public class AllMsgTextRender {
|
||||
//用这个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);
|
||||
blind(spannableStringBuilder, textView, serverNotifyEvent, giftNameIndex, endName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
blind(spannableStringBuilder,textView,serverNotifyEvent,giftNameIndex,endName);
|
||||
blind(spannableStringBuilder, textView, serverNotifyEvent, giftNameIndex, endName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void blind( SpannableStringBuilder spannableStringBuilder, TextView textView, AllServerNotifyEvent serverNotifyEvent, int giftNameIndex,int 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")),
|
||||
|
||||
BIN
live/src/main/res/mipmap-mdpi/backdrop_luck.png
Normal file
BIN
live/src/main/res/mipmap-mdpi/backdrop_luck.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
BIN
live/src/main/res/mipmap-mdpi/icon_luck.png
Normal file
BIN
live/src/main/res/mipmap-mdpi/icon_luck.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
Reference in New Issue
Block a user