修改直播间聊天字体背景样式
This commit is contained in:
parent
c2aba5da4b
commit
be608fd90b
@ -4,14 +4,14 @@ ext {
|
||||
buildToolsVersion: "29.0.2",
|
||||
minSdkVersion : 21,
|
||||
targetSdkVersion : 31,
|
||||
versionCode : 413,
|
||||
versionCode : 414,
|
||||
versionName : "6.4.9"
|
||||
]
|
||||
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",
|
||||
|
BIN
live/src/main/assets/chat_message_bg.png
Normal file
BIN
live/src/main/assets/chat_message_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 540 B |
@ -202,13 +202,13 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
void setData(final LiveChatBean bean, int position) {
|
||||
|
||||
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);
|
||||
mBg.setLayoutParams(params);
|
||||
if (bean.getType() == 6) {//大作战活动
|
||||
view_action_game.setVisibility(View.VISIBLE);
|
||||
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);
|
||||
mBg.setLayoutParams(params);
|
||||
|
||||
@ -238,9 +238,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
} else if (bean.getType() == -3 || bean.getType() == -4 || bean.getType() == -5) {//整蛊
|
||||
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
|
||||
//加载.9图聊天气泡
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
} 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();
|
||||
if (bean.getType() == -3) {
|
||||
@ -278,9 +279,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
} else if (bean.getType() == -6) {
|
||||
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
|
||||
//加载.9图聊天气泡
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
} 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 str2 = "為本直播間加成熱度";
|
||||
@ -297,9 +299,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
} else if (bean.getType() == -7) {
|
||||
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
|
||||
//加载.9图聊天气泡
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
} 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 str2 = "在甜蜜約會中搶購到了";
|
||||
@ -359,23 +362,23 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
bean.setHeart(position);
|
||||
} else if (bean.getType() == RECOMMEND_CARD_NOTIFY) {
|
||||
//加载.9图聊天气泡
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
new LiveTextRender().recommendCardNotify(mContext, mTextView, bean);
|
||||
} else if (bean.getType() == AI_AUTOMATIC_SPEECH) {
|
||||
//加载.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());
|
||||
} else if (bean.getType() == STAR_CHALLENGE_UPGRADE_NOTIFY) {
|
||||
//加载.9图聊天气泡
|
||||
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());
|
||||
}
|
||||
} else if (bean.getType() == LUCKY_ANGEL) {
|
||||
if (!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())) {
|
||||
bean.setId(bean.getMsgModel().getUserId());
|
||||
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());
|
||||
}
|
||||
|
||||
@ -383,16 +386,17 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
if (!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())) {
|
||||
bean.setId(bean.getMsgModel().getUserId());
|
||||
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());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
|
||||
//加载.9图聊天气泡
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
} 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) {
|
||||
mTextView.setTextColor(0xffc8c8c8);
|
||||
|
@ -303,7 +303,7 @@ public class LiveEnterRoomAnimPresenter {
|
||||
enter_room_gif_small.setVisibility(View.GONE);
|
||||
tv_enterroom_user.setText(playText);
|
||||
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);
|
||||
|
||||
if (enter_room_svg_small != null) {
|
||||
@ -509,7 +509,7 @@ public class LiveEnterRoomAnimPresenter {
|
||||
enter_room_gif_small.setVisibility(View.VISIBLE);
|
||||
tv_enterroom_user.setText(playText);
|
||||
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);
|
||||
mGifDrawable.setLoopCount(3);
|
||||
view = enter_room_gif_small;
|
||||
|
@ -2,15 +2,17 @@ package com.yunbao.live.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.NinePatch;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.NinePatchDrawable;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
@ -19,13 +21,15 @@ import com.yunbao.live.activity.LiveActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LoadDian9TuUtil {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@ -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)
|
||||
return;
|
||||
byte[] chunk = bitmap.getNinePatchChunk();
|
||||
@ -71,7 +100,7 @@ public class LoadDian9TuUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LiveActivity#onDestroy() 结束时,释放掉.9图缓存
|
||||
* @see LiveActivity# 结束时,释放掉.9图缓存
|
||||
*/
|
||||
public static void clearBitmap() {
|
||||
for (Bitmap bitmap : BITMAP_CACHE) {
|
||||
|
@ -5,7 +5,6 @@
|
||||
android:id="@+id/bg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@ -14,7 +13,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
android:layout_marginLeft="9dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginRight="9dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:textColor="@color/white"
|
||||
|
Loading…
Reference in New Issue
Block a user