修改直播间聊天字体背景样式

This commit is contained in:
18401019693 2023-03-21 17:42:34 +08:00
parent c2aba5da4b
commit be608fd90b
6 changed files with 64 additions and 32 deletions

View File

@ -4,14 +4,14 @@ ext {
buildToolsVersion: "29.0.2", buildToolsVersion: "29.0.2",
minSdkVersion : 21, minSdkVersion : 21,
targetSdkVersion : 31, targetSdkVersion : 31,
versionCode : 413, versionCode : 414,
versionName : "6.4.9" versionName : "6.4.9"
] ]
manifestPlaceholders = [ manifestPlaceholders = [
// //
// serverHost : "https://napi.yaoulive.com", serverHost : "https://napi.yaoulive.com",
// //
serverHost : "https://ceshi.yaoulive.com", // serverHost : "https://ceshi.yaoulive.com",
// //
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

View File

@ -202,13 +202,13 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
void setData(final LiveChatBean bean, int position) { void setData(final LiveChatBean bean, int position) {
itemView.setTag(bean); itemView.setTag(bean);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 0, DpUtil.dp2px(95), 12); params.setMargins(0, 0, DpUtil.dp2px(95), 12);
mBg.setLayoutParams(params); mBg.setLayoutParams(params);
if (bean.getType() == 6) {//大作战活动 if (bean.getType() == 6) {//大作战活动
view_action_game.setVisibility(View.VISIBLE); view_action_game.setVisibility(View.VISIBLE);
bean.setHeart(position); bean.setHeart(position);
params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 0, 80, 12); params.setMargins(0, 0, 80, 12);
mBg.setLayoutParams(params); mBg.setLayoutParams(params);
@ -238,9 +238,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
} else if (bean.getType() == -3 || bean.getType() == -4 || bean.getType() == -5) {//整蛊 } else if (bean.getType() == -3 || bean.getType() == -4 || bean.getType() == -5) {//整蛊
if (bean.getBubble() != null && !bean.getBubble().equals("")) { if (bean.getBubble() != null && !bean.getBubble().equals("")) {
//加载.9图聊天气泡 //加载.9图聊天气泡
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1); new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
} else { } else {
mBg.setBackgroundResource(R.drawable.bg_live_chat_item); // mBg.setBackgroundResource(R.drawable.bg_live_chat_item);
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg,1);
} }
SpannableStringBuilder builder = new SpannableStringBuilder(); SpannableStringBuilder builder = new SpannableStringBuilder();
if (bean.getType() == -3) { if (bean.getType() == -3) {
@ -278,9 +279,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
} else if (bean.getType() == -6) { } else if (bean.getType() == -6) {
if (bean.getBubble() != null && !bean.getBubble().equals("")) { if (bean.getBubble() != null && !bean.getBubble().equals("")) {
//加载.9图聊天气泡 //加载.9图聊天气泡
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1); new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
} else { } else {
mBg.setBackgroundResource(R.drawable.bg_live_chat_item); // mBg.setBackgroundResource(R.drawable.bg_live_chat_item);
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg,1);
} }
String str1 = "火力四射,魅力無限!感謝"; String str1 = "火力四射,魅力無限!感謝";
String str2 = "為本直播間加成熱度"; String str2 = "為本直播間加成熱度";
@ -297,9 +299,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
} else if (bean.getType() == -7) { } else if (bean.getType() == -7) {
if (bean.getBubble() != null && !bean.getBubble().equals("")) { if (bean.getBubble() != null && !bean.getBubble().equals("")) {
//加载.9图聊天气泡 //加载.9图聊天气泡
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1); new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
} else { } else {
mBg.setBackgroundResource(R.drawable.bg_live_chat_item); // mBg.setBackgroundResource(R.drawable.bg_live_chat_item);
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg,1);
} }
String str1 = "甜蜜不停,愛意不斷!恭喜"; String str1 = "甜蜜不停,愛意不斷!恭喜";
String str2 = "在甜蜜約會中搶購到了"; String str2 = "在甜蜜約會中搶購到了";
@ -359,23 +362,23 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
bean.setHeart(position); bean.setHeart(position);
} else if (bean.getType() == RECOMMEND_CARD_NOTIFY) { } else if (bean.getType() == RECOMMEND_CARD_NOTIFY) {
//加载.9图聊天气泡 //加载.9图聊天气泡
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1); new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
new LiveTextRender().recommendCardNotify(mContext, mTextView, bean); new LiveTextRender().recommendCardNotify(mContext, mTextView, bean);
} else if (bean.getType() == AI_AUTOMATIC_SPEECH) { } else if (bean.getType() == AI_AUTOMATIC_SPEECH) {
//加载.9图聊天气泡 //加载.9图聊天气泡
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getAiAutomaticSpeechModel().getSystemBubble(), 1); new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getAiAutomaticSpeechModel().getSystemBubble(), 1);
new LiveTextRender().aiAutomaticSpeech(mContext, mTextView, bean.getAiAutomaticSpeechModel()); new LiveTextRender().aiAutomaticSpeech(mContext, mTextView, bean.getAiAutomaticSpeechModel());
} else if (bean.getType() == STAR_CHALLENGE_UPGRADE_NOTIFY) { } else if (bean.getType() == STAR_CHALLENGE_UPGRADE_NOTIFY) {
//加载.9图聊天气泡 //加载.9图聊天气泡
if (!TextUtils.isEmpty(bean.getMsgModel().getSystemBubble())) { if (!TextUtils.isEmpty(bean.getMsgModel().getSystemBubble())) {
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystemBubble(), 1); new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystemBubble(), 1);
new LiveTextRender().starChallengeUpgradeNotify(mContext, mTextView, bean.getMsgModel()); new LiveTextRender().starChallengeUpgradeNotify(mContext, mTextView, bean.getMsgModel());
} }
} else if (bean.getType() == LUCKY_ANGEL) { } else if (bean.getType() == LUCKY_ANGEL) {
if (!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())) { if (!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())) {
bean.setId(bean.getMsgModel().getUserId()); bean.setId(bean.getMsgModel().getUserId());
itemView.setTag(bean); itemView.setTag(bean);
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystem_bubble(), 1); new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystem_bubble(), 1);
new LiveTextRender().luckyAngel(mContext, mTextView, bean.getMsgModel()); new LiveTextRender().luckyAngel(mContext, mTextView, bean.getMsgModel());
} }
@ -383,16 +386,17 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
if (!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())) { if (!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())) {
bean.setId(bean.getMsgModel().getUserId()); bean.setId(bean.getMsgModel().getUserId());
itemView.setTag(bean); itemView.setTag(bean);
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystem_bubble(), 1); new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystem_bubble(), 1);
new LiveTextRender().lucky100(mContext, mTextView, bean.getMsgModel()); new LiveTextRender().lucky100(mContext, mTextView, bean.getMsgModel());
} }
} }
else { else {
if (bean.getBubble() != null && !bean.getBubble().equals("")) { if (bean.getBubble() != null && !bean.getBubble().equals("")) {
//加载.9图聊天气泡 //加载.9图聊天气泡
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1); new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
} else { } else {
mBg.setBackgroundResource(R.drawable.bg_live_chat_item); // mBg.setBackgroundResource(R.drawable.bg_live_chat_item);
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg,1);
} }
if (bean.getType() == LiveChatBean.ENTER_ROOM || bean.getType() == LiveChatBean.LIGHT) { if (bean.getType() == LiveChatBean.ENTER_ROOM || bean.getType() == LiveChatBean.LIGHT) {
mTextView.setTextColor(0xffc8c8c8); mTextView.setTextColor(0xffc8c8c8);

View File

@ -303,7 +303,7 @@ public class LiveEnterRoomAnimPresenter {
enter_room_gif_small.setVisibility(View.GONE); enter_room_gif_small.setVisibility(View.GONE);
tv_enterroom_user.setText(playText); tv_enterroom_user.setText(playText);
tv_enterroom_user.setTextColor(Color.parseColor(colocNow)); tv_enterroom_user.setTextColor(Color.parseColor(colocNow));
LoadDian9TuUtil.loadDian9Tu(mContext, tv_enterroom_user, urlNow, 0); new LoadDian9TuUtil().loadDian9Tu(mContext, tv_enterroom_user, urlNow, 0);
playStart(rt_enterroom_svga); playStart(rt_enterroom_svga);
if (enter_room_svg_small != null) { if (enter_room_svg_small != null) {
@ -339,7 +339,7 @@ public class LiveEnterRoomAnimPresenter {
SVGARect rect = svgaVideoEntity.getVideoSize(); SVGARect rect = svgaVideoEntity.getVideoSize();
mSVGImageView.setVideoItem(svgaVideoEntity); mSVGImageView.setVideoItem(svgaVideoEntity);
mSVGImageView.setLoops(1); mSVGImageView.setLoops(1);
SVGAViewUtils.playEndClear(mSVGImageView,true,new SVGACallback() { SVGAViewUtils.playEndClear(mSVGImageView, true, new SVGACallback() {
@Override @Override
public void onPause() { public void onPause() {
@ -509,7 +509,7 @@ public class LiveEnterRoomAnimPresenter {
enter_room_gif_small.setVisibility(View.VISIBLE); enter_room_gif_small.setVisibility(View.VISIBLE);
tv_enterroom_user.setText(playText); tv_enterroom_user.setText(playText);
tv_enterroom_user.setTextColor(Color.parseColor(colocNow)); tv_enterroom_user.setTextColor(Color.parseColor(colocNow));
LoadDian9TuUtil.loadDian9Tu(mContext, tv_enterroom_user, urlNow, 0); new LoadDian9TuUtil().loadDian9Tu(mContext, tv_enterroom_user, urlNow, 0);
playStart(rt_enterroom_svga); playStart(rt_enterroom_svga);
mGifDrawable.setLoopCount(3); mGifDrawable.setLoopCount(3);
view = enter_room_gif_small; view = enter_room_gif_small;

View File

@ -2,15 +2,17 @@ package com.yunbao.live.utils;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.NinePatch; import android.graphics.NinePatch;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable; import android.graphics.drawable.NinePatchDrawable;
import android.os.Build; import android.os.Build;
import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import android.view.View;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.CustomTarget;
@ -19,13 +21,15 @@ import com.yunbao.live.activity.LiveActivity;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class LoadDian9TuUtil { public class LoadDian9TuUtil {
private static final List<Bitmap> BITMAP_CACHE=new ArrayList<>();//.9图Bitmap缓存 private static final List<Bitmap> BITMAP_CACHE = new ArrayList<>();//.9图Bitmap缓存
public static void loadDian9Tu(Context context, View imageView, String imgUrl, int position) { public void loadDian9Tu(Context context, View imageView, String imgUrl, int position) {
if (context == null) { if (context == null) {
return; return;
} }
@ -43,8 +47,8 @@ public class LoadDian9TuUtil {
@Override @Override
public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) { public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {
try { try {
FileInputStream is=new FileInputStream(resource); FileInputStream is = new FileInputStream(resource);
Bitmap bitmap=BitmapFactory.decodeStream(is); Bitmap bitmap = BitmapFactory.decodeStream(is);
BITMAP_CACHE.add(bitmap); BITMAP_CACHE.add(bitmap);
setNinePathImage(context, imageView, bitmap, position); setNinePathImage(context, imageView, bitmap, position);
is.close(); is.close();
@ -60,7 +64,32 @@ public class LoadDian9TuUtil {
}); });
} }
public static void setNinePathImage(Context context, View imageView, Bitmap bitmap, int position) { public void loadDian9TuAssets(Context context, View imageView, int position) {
Bitmap bitmap = getImageFromAssetsFile(context, "chat_message_bg.png");
BITMAP_CACHE.add(bitmap);
setNinePathImage(context, imageView, bitmap, position);
}
/**
* 从Assets中读取图片
*
* @param fileName
* @return
*/
private Bitmap getImageFromAssetsFile(Context context, String fileName) {
Bitmap image = null;
AssetManager am = context.getResources().getAssets();
try {
InputStream is = am.open(fileName);
image = BitmapFactory.decodeStream(is);
is.close();
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
public void setNinePathImage(Context context, View imageView, Bitmap bitmap, int position) {
if (bitmap == null) if (bitmap == null)
return; return;
byte[] chunk = bitmap.getNinePatchChunk(); byte[] chunk = bitmap.getNinePatchChunk();
@ -71,11 +100,11 @@ public class LoadDian9TuUtil {
} }
/** /**
* @see LiveActivity#onDestroy() 结束时释放掉.9图缓存 * @see LiveActivity# 结束时释放掉.9图缓存
*/ */
public static void clearBitmap(){ public static void clearBitmap() {
for (Bitmap bitmap : BITMAP_CACHE) { for (Bitmap bitmap : BITMAP_CACHE) {
if(bitmap!=null) { if (bitmap != null) {
bitmap.recycle(); bitmap.recycle();
} }
} }

View File

@ -5,7 +5,6 @@
android:id="@+id/bg" android:id="@+id/bg"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
@ -14,7 +13,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="left" android:layout_gravity="left"
android:layout_marginLeft="9dp" android:layout_marginLeft="9dp"
android:layout_marginTop="6dp" android:layout_marginTop="4dp"
android:layout_marginRight="9dp" android:layout_marginRight="9dp"
android:layout_marginBottom="6dp" android:layout_marginBottom="6dp"
android:textColor="@color/white" android:textColor="@color/white"