From 8cbbd4015f2e0b208e1186f9a5562e0dd03dd174 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Fri, 7 Apr 2023 17:34:39 +0800 Subject: [PATCH] xiu gai xinyuan dan --- .../live/activity/LiveAudienceActivity.java | 2 +- .../yunbao/live/adapter/LiveChatAdapter.java | 77 ++++++++++++------- .../yunbao/live/socket/SocketRyClient.java | 2 +- .../yunbao/live/views/LiveRoomViewHolder.java | 3 +- .../live/views/PortraitLiveManager.java | 4 +- 5 files changed, 56 insertions(+), 32 deletions(-) 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 26445c8b1..cf0a289d3 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -1298,7 +1298,7 @@ public class LiveAudienceActivity extends LiveActivity { break; case WISH_LIST_PROGRESS: if (manager != null) { - manager.wishListProgress(event.getWishListProgress(), event.getUname()); + manager.wishListProgress(event.getWishListProgress(), event.getUname(),event.getLiveType()); } break; case XYD_COMPLETE: 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 53a9d1d98..57793d831 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -13,7 +13,6 @@ import android.content.Context; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.text.Html; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -40,6 +39,7 @@ import com.makeramen.roundedimageview.RoundedImageView; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.custom.VerticalImageSpan; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.manager.IMLoginManager; @@ -401,18 +401,11 @@ public class LiveChatAdapter extends RecyclerView.Adapter { //加载.9图聊天气泡 new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1); xydComplete.setVisibility(View.VISIBLE); - textTxt2.setText(userNicenamehighlight(bean.getContent(), bean.getAtUserName(), bean.getUserNiceName())); - mTextView.setVisibility(View.GONE); - textLeave.setVisibility(View.GONE); - } else if (bean.getType() == XYD_COMPLETE) { - //加载.9图聊天气泡 - new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1); - xydComplete.setVisibility(View.VISIBLE); - textTxt2.setText(userNicenamehighlight(bean.getContent(), bean.getAtUserName(), bean.getUserNiceName())); - new LiveTextRender().getLiveLevelImage(mContext, bean.getLevel(), false,new ImgLoader.DrawableCallback() { + + new LiveTextRender().getLiveLevelImage(mContext, bean.getLevel(), false, new ImgLoader.DrawableCallback() { @Override public void onLoadSuccess(Drawable drawable) { - ImgLoader.display2(mContext, drawable, textLeave); + textTxt2.setText(userNicenamehighlight(bean.getContent(), bean.getAtUserName(), bean.getUserNiceName(), drawable)); } @Override @@ -421,6 +414,25 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } }); mTextView.setVisibility(View.GONE); + textLeave.setVisibility(View.GONE); + } else if (bean.getType() == XYD_COMPLETE) { + //加载.9图聊天气泡 + new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1); + xydComplete.setVisibility(View.VISIBLE); + + new LiveTextRender().getLiveLevelImage(mContext, bean.getLevel(), false, new ImgLoader.DrawableCallback() { + @Override + public void onLoadSuccess(Drawable drawable) { + textTxt2.setText(userNicenamehighlight(bean.getContent(), bean.getAtUserName(), bean.getUserNiceName(), drawable)); + } + + @Override + public void onLoadFailed() { + + } + }); + mTextView.setVisibility(View.GONE); + textLeave.setVisibility(View.GONE); } else if (bean.getType() == AI_AUTOMATIC_SPEECH) { //加载.9图聊天气泡 new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getAiAutomaticSpeechModel().getSystemBubble(), 1); @@ -633,22 +645,33 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } - private Spanned userNicenamehighlight(String context, String keyword, String keyword2) { - String contextHtml = ""; - String keywordHtml2; - String keywordHtml; - if (TextUtils.isEmpty(keyword) || TextUtils.isEmpty(keyword2)) { - keywordHtml2 = TextUtils.isEmpty(keyword) ? "1" : keyword; - keywordHtml = TextUtils.isEmpty(keyword) ? "1" : keyword; - } else { - keywordHtml2 = "" + keyword + ""; - keywordHtml = "" + keyword2 + ""; + private Spanned userNicenamehighlight(String context, String keyword, String keyword2, Drawable levelDrawable) { +// String contextHtml = ""; +// String keywordHtml2; +// String keywordHtml; +// if (TextUtils.isEmpty(keyword) || TextUtils.isEmpty(keyword2)) { +// keywordHtml2 = TextUtils.isEmpty(keyword) ? "1" : keyword; +// keywordHtml = TextUtils.isEmpty(keyword) ? "1" : keyword; +// } else { +// keywordHtml2 = "" + keyword + ""; +// keywordHtml = "" + keyword2 + ""; +// } +// +// contextHtml = "" + context + ""; +// contextHtml = contextHtml.replace(keyword, keywordHtml2).replace(keyword2, keywordHtml); + + SpannableStringBuilder builder = new SpannableStringBuilder(); + int index = 0; + + if (levelDrawable != null) { + builder.append(" "); + levelDrawable.setBounds(0, 0, DpUtil.dp2px(18), DpUtil.dp2px(18)); + builder.setSpan(new VerticalImageSpan(levelDrawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + index = builder.length(); } - - contextHtml = "" + context + ""; - contextHtml = contextHtml.replace(keyword, keywordHtml2).replace(keyword2, keywordHtml); - - - return Html.fromHtml(contextHtml); + builder.append(context); + builder.setSpan(new ForegroundColorSpan(Color.parseColor("#4BFFD4")), index + context.indexOf(keyword), index + context.indexOf(keyword) + keyword.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + builder.setSpan(new ForegroundColorSpan(Color.parseColor("#4BFFD4")), index + context.indexOf(keyword2), index + context.indexOf(keyword2) + keyword2.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + return builder; } } 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 2bd1727ac..8879a2222 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -615,7 +615,7 @@ public class SocketRyClient { .setWishlistName(map.getString("wishlist_name")) .setWishlistNum(map.getString("wishlist_num")) .setGiftType(map.getInteger("giftId")) - .setLuid(conString.toString())).setUname(map.getString("userName"))); + .setLuid(conString.toString())).setUname(map.getString("userName")).setLiveType(Integer.parseInt(map.getString("level")))); break; } 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 d6514eba3..b92ac4235 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -4234,7 +4234,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } - public void wishListProgress(WishModel wishModel, String userNiceName) { + public void wishListProgress(WishModel wishModel, String userNiceName,int level) { wishListProgress = null; WishModel model = wishModel; if (!TextUtils.isEmpty(model.getWishlistName()) || !TextUtils.isEmpty(model.getWishlistProgress())) { @@ -4261,6 +4261,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis bean.setUserNiceName(userNiceName); bean.setAtUserName(model.getWishlistName()); bean.setType(LiveChatBean.WISH_LIST_PROGRESS); + bean.setLevel(level); mLiveChatAdapter.insertItem(bean); topBanner1.update(mTopBannerList); } 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 4468c48cc..60f7c90fb 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -1945,9 +1945,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } } - public void wishListProgress(WishModel wishListProgress, String userNiceName) { + public void wishListProgress(WishModel wishListProgress, String userNiceName,int level) { if (mLiveRoomViewHolder != null) { - mLiveRoomViewHolder.wishListProgress(wishListProgress, userNiceName); + mLiveRoomViewHolder.wishListProgress(wishListProgress, userNiceName,level); } } public void showXydComplete(XydCompleteModel model) {