fix[修复BUG]

This commit is contained in:
Martin 2024-06-03 15:41:29 +08:00
parent 4bd1e4bc91
commit 1b57d8bc8f
6 changed files with 136 additions and 38 deletions

View File

@ -80,9 +80,9 @@ public class CommonAppConfig {
public static String SWToken = ""; //声网Token public static String SWToken = ""; //声网Token
public static final String SWChannelPrefix = "g"; public static final String SWChannelPrefix = "g";
//测试服 //测试服
public static final String SWAPPId = "4cf0376582d742ac8a96778b25b1079e"; //public static final String SWAPPId = "4cf0376582d742ac8a96778b25b1079e";
//正式服 //正式服
//public static final String SWAPPId = "d4a5879524d74c20a7bdd667b0f2ca21"; public static final String SWAPPId = "d4a5879524d74c20a7bdd667b0f2ca21";

View File

@ -36,6 +36,9 @@ import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.enums.PopupPosition; import com.lxj.xpopup.enums.PopupPosition;
import com.lxj.xpopup.interfaces.XPopupCallback; import com.lxj.xpopup.interfaces.XPopupCallback;
import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.EasyFloat;
import com.lzf.easyfloat.enums.ShowPattern;
import com.yunbao.common.dialog.DebugDialog;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
@ -127,6 +130,7 @@ import com.yunbao.live.event.LinkMicTxAccEvent;
import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.event.LiveOpenSuccessEvent; import com.yunbao.live.event.LiveOpenSuccessEvent;
import com.yunbao.live.http.ImHttpUtil; import com.yunbao.live.http.ImHttpUtil;
import com.yunbao.live.utils.LiveTextRender;
import com.yunbao.live.views.LiveRoomPlayViewHolder; import com.yunbao.live.views.LiveRoomPlayViewHolder;
import com.yunbao.live.views.LiveRoomViewHolder; import com.yunbao.live.views.LiveRoomViewHolder;
import com.yunbao.live.views.PortraitLiveManager; import com.yunbao.live.views.PortraitLiveManager;
@ -227,6 +231,27 @@ public class LiveAudienceActivity extends LiveActivity {
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "YoursystemisolderDialog"); fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "YoursystemisolderDialog");
IMLoginManager.get(mContext).setXiaJBG(true); IMLoginManager.get(mContext).setXiaJBG(true);
} }
/*new Handler(Looper.getMainLooper())
.postDelayed(new Runnable() {
@Override
public void run() {
System.out.println("------------------------初始化弹窗------------------------");
DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
@Override
public void run(DebugDialog dialog) {
System.out.println("------------------------显示弹窗------------------------");
dialog.setShowPattern(ShowPattern.ALL_TIME);
dialog.show();
LiveTextRender.onItemClickListener = new OnItemClickListener<String>() {
@Override
public void onItemClick(String bean, int position) {
dialog.setParams(bean.split("\\|")[0], bean.split("\\|")[1]);
}
};
}
});
}
},1000);*/
} }
private final MicStatusManager.OnMicStatusListener onMicStatusListener = new MicStatusManager.OnMicStatusListener() { private final MicStatusManager.OnMicStatusListener onMicStatusListener = new MicStatusManager.OnMicStatusListener() {

View File

@ -21,6 +21,7 @@ import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.MeasureSpec; import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -31,13 +32,16 @@ import androidx.core.content.ContextCompat;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition; import com.bumptech.glide.request.transition.Transition;
import com.lzf.easyfloat.enums.ShowPattern;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.AiAutomaticSpeechModel; import com.yunbao.common.bean.AiAutomaticSpeechModel;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.NewGuardLevelModel; import com.yunbao.common.bean.NewGuardLevelModel;
import com.yunbao.common.bean.NewLevelModel; import com.yunbao.common.bean.NewLevelModel;
import com.yunbao.common.custom.VerticalImageSpan; import com.yunbao.common.custom.VerticalImageSpan;
import com.yunbao.common.dialog.DebugDialog;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.NewLevelManager; import com.yunbao.common.manager.NewLevelManager;
import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.StringUtil;
@ -83,6 +87,10 @@ public class LiveTextRender {
sFontSizeSpan = new AbsoluteSizeSpan(17, true); sFontSizeSpan = new AbsoluteSizeSpan(17, true);
sFontSizeSpan2 = new AbsoluteSizeSpan(12, true); sFontSizeSpan2 = new AbsoluteSizeSpan(12, true);
sFontSizeSpan3 = new AbsoluteSizeSpan(14, true); sFontSizeSpan3 = new AbsoluteSizeSpan(14, true);
if (!isInit) {
isInit = true;
}
} }
public void blindBox(Context context, TextView textView, LiveChatBean bean) { public void blindBox(Context context, TextView textView, LiveChatBean bean) {
@ -263,7 +271,7 @@ public class LiveTextRender {
} }
public interface CreatePrefixCallback { public interface CreatePrefixCallback {
void onPrefixCallback(SpannableStringBuilder builder); void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth);
} }
/** /**
@ -284,7 +292,7 @@ public class LiveTextRender {
getGuardImage(CommonAppContext.sInstance, bean.getGuardType(), new ImgLoader.DrawableCallback() { getGuardImage(CommonAppContext.sInstance, bean.getGuardType(), new ImgLoader.DrawableCallback() {
@Override @Override
public void onLoadSuccess(Drawable drawable) { public void onLoadSuccess(Drawable drawable) {
SpannableStringBuilder builder = new SpannableStringBuilder(); /*SpannableStringBuilder builder = new SpannableStringBuilder();
int index = 0; int index = 0;
if (levelDrawable != null) { if (levelDrawable != null) {
@ -353,19 +361,25 @@ public class LiveTextRender {
index = builder.length(); index = builder.length();
} }
} }
createPrefixCallback.onPrefixCallback(builder); createPrefixCallback.onPrefixCallback(builder, 0);*/
show(drawable);
} }
@Override @Override
public void onLoadFailed() { public void onLoadFailed() {
show(null);
}
void show(Drawable drawable) {
SpannableStringBuilder builder = new SpannableStringBuilder(); SpannableStringBuilder builder = new SpannableStringBuilder();
int index = 0; int index = 0;
int prefixWidth = 0;
if (levelDrawable != null) { if (levelDrawable != null) {
builder.append(" "); builder.append(" ");
levelDrawable.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(17)); levelDrawable.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(levelDrawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new VerticalImageSpan(levelDrawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length(); index = builder.length();
prefixWidth += levelDrawable.getBounds().width();
} }
if (gzDrawablesMap.containsKey(bean)) {//贵族 if (gzDrawablesMap.containsKey(bean)) {//贵族
@ -373,6 +387,7 @@ public class LiveTextRender {
gzDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(35), DpUtil.dp2px(20)); gzDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(35), DpUtil.dp2px(20));
builder.setSpan(new VerticalImageSpan(gzDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new VerticalImageSpan(gzDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length(); index = builder.length();
prefixWidth += gzDrawablesMap.get(bean).getBounds().width();
} }
if (ryxzDrawablesMap.containsKey(bean)) {//荣誉勋章 if (ryxzDrawablesMap.containsKey(bean)) {//荣誉勋章
@ -380,6 +395,7 @@ public class LiveTextRender {
ryxzDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(18), DpUtil.dp2px(18)); ryxzDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(18), DpUtil.dp2px(18));
builder.setSpan(new VerticalImageSpan(ryxzDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new VerticalImageSpan(ryxzDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length(); index = builder.length();
prefixWidth += ryxzDrawablesMap.get(bean).getBounds().width();
} }
if (nhDrawablesMap.containsKey(bean)) {//靓号 if (nhDrawablesMap.containsKey(bean)) {//靓号
@ -387,41 +403,52 @@ public class LiveTextRender {
nhDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(17)); nhDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(nhDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new VerticalImageSpan(nhDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length(); index = builder.length();
prefixWidth += nhDrawablesMap.get(bean).getBounds().width();
}
if (drawable != null) {
builder.append(" ");
drawable.setBounds(0, 0, DpUtil.dp2px(34), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
prefixWidth += drawable.getBounds().width();
} }
//在这里添加粉丝徽章的图片 //在这里添加粉丝徽章的图片
if (!TextUtils.isEmpty(bean.getMedalNmae()) && !TextUtils.isEmpty(bean.getMedalLevelImageUrl()) if (!TextUtils.isEmpty(bean.getMedalNmae()) && !TextUtils.isEmpty(bean.getMedalLevelImageUrl())
&& !bean.getMedalNmae().equals("null") && !bean.getMedalNmae().equals("(null)") && !bean.getMedalNmae().equals("<null>")) {//粉丝徽章图标 && !bean.getMedalNmae().equals("null") && !bean.getMedalNmae().equals("(null)") && !bean.getMedalNmae().equals("<null>")) {//粉丝徽章图标
Drawable drawable = getMedalImage(bean); drawable = getMedalImage(bean);
if (drawable != null) { if (drawable != null) {
builder.append(" "); builder.append(" ");
drawable.setBounds(0, 0, DpUtil.dp2px(44), DpUtil.dp2px(17)); drawable.setBounds(0, 0, DpUtil.dp2px(44), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length(); index = builder.length();
prefixWidth += drawable.getBounds().width();
} }
} }
if (bean.isManager()) {//直播间管理员图标 if (bean.isManager()) {//直播间管理员图标
Drawable drawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_m); drawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_m);
if (drawable != null) { if (drawable != null) {
builder.append(" "); builder.append(" ");
drawable.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(14)); drawable.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(14));
builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length(); index = builder.length();
prefixWidth += drawable.getBounds().width();
} }
} }
if (!TextUtils.isEmpty(bean.getLiangName())) {//靓号图标 if (!TextUtils.isEmpty(bean.getLiangName())) {//靓号图标
Drawable drawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_liang); drawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_liang);
if (drawable != null) { if (drawable != null) {
builder.append(" "); builder.append(" ");
drawable.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(14)); drawable.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(14));
builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// new add // new add
index = builder.length(); index = builder.length();
prefixWidth += drawable.getBounds().width();
} }
} }
createPrefixCallback.onPrefixCallback(builder); createPrefixCallback.onPrefixCallback(builder, prefixWidth);
} }
}); });
@ -684,7 +711,7 @@ public class LiveTextRender {
createPrefix(drawable, bean, new CreatePrefixCallback() { createPrefix(drawable, bean, new CreatePrefixCallback() {
@Override @Override
public void onPrefixCallback(SpannableStringBuilder builder) { public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int color = Color.parseColor("#68F1F4"); int color = Color.parseColor("#68F1F4");
if (bean.isAnchor()) { if (bean.isAnchor()) {
color = Color.parseColor("#FBEABF"); color = Color.parseColor("#FBEABF");
@ -696,20 +723,20 @@ public class LiveTextRender {
builder = renderGift(color, builder, bean); builder = renderGift(color, builder, bean);
break; break;
default: default:
builder = renderChat(color, builder, bean); builder = renderChat(textView, color, builder, bean, prefixWidth);
break; break;
} }
textView.setText(builder); textView.setText(builder);
} }
}); });
} }// 123123123123123123123123
@Override @Override
public void onLoadFailed() { public void onLoadFailed() {
createPrefix(null, bean, new CreatePrefixCallback() { createPrefix(null, bean, new CreatePrefixCallback() {
@Override @Override
public void onPrefixCallback(SpannableStringBuilder builder) { public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int color = 0; int color = 0;
if (bean.isAnchor()) { if (bean.isAnchor()) {
color = 0xffffdd00; color = 0xffffdd00;
@ -721,7 +748,7 @@ public class LiveTextRender {
builder = renderGift(color, builder, bean); builder = renderGift(color, builder, bean);
break; break;
default: default:
builder = renderChat(color, builder, bean); builder = renderChat(textView, color, builder, bean, prefixWidth);
break; break;
} }
textView.setText(builder); textView.setText(builder);
@ -805,15 +832,46 @@ public class LiveTextRender {
return mNewBitmap; return mNewBitmap;
} }
public static OnItemClickListener<String> onItemClickListener=new OnItemClickListener<String>() {
@Override
public void onItemClick(String bean, int position) {
}
};
private static boolean isInit = false;
/** /**
* 渲染普通聊天消息 * 渲染普通聊天消息
*/ */
private SpannableStringBuilder renderChat(int color, SpannableStringBuilder builder, LiveChatBean bean) { private SpannableStringBuilder renderChat(TextView textView, int color, SpannableStringBuilder builder, LiveChatBean bean, int prefixWidth) {
int length = builder.length(); int length = builder.length();
String name = bean.getUserNiceName(); String name = bean.getUserNiceName();
if (bean.getType() != LiveChatBean.ENTER_ROOM) {//产品规定进场消息不允许加冒号 if (bean.getType() != LiveChatBean.ENTER_ROOM) {//产品规定进场消息不允许加冒号
name += ""; name += "";
} }
SpannableStringBuilder sb = new SpannableStringBuilder();
sb.append(builder).append(name).append(" ");
float measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
int width = ((ViewGroup) textView.getParent()).getWidth();
onItemClickListener.onItemClick("测算|" + measuredText, 0);
onItemClickListener.onItemClick("控件宽度|" + width, 0);
onItemClickListener.onItemClick("前缀预留宽度|" + prefixWidth, 0);
//检测渲染后图标+名字是否超过父布局宽度超过了就做换行处理
if (measuredText > width) {
sb.clear();
sb.append(builder);
for (int i = 0; i < name.length(); i++) {
sb.append(name.charAt(i));
measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
onItemClickListener.onItemClick(i + "逐测算|" + measuredText, 0);
if (measuredText > width) {
name = name.substring(0, i - 1) + "\n" + name.substring(i -1);
break;
}
}
sb.clear();
}
// name=name.substring(0,7)+"\n"+name.substring(7);
builder.append(name); builder.append(name);
//超皇设置渐变色展示昵称 //超皇设置渐变色展示昵称
if (TextUtils.equals("7", bean.getNobleId()) && !TextUtils.isEmpty(bean.getStartColor())) { if (TextUtils.equals("7", bean.getNobleId()) && !TextUtils.isEmpty(bean.getStartColor())) {
@ -823,6 +881,24 @@ public class LiveTextRender {
builder.setSpan(new ForegroundColorSpan(color), length, length + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new ForegroundColorSpan(color), length, length + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
int lengthContent = builder.length(); int lengthContent = builder.length();
//这一段先别删万一后面要改内容换行呢
/* sb.clear();
sb.append(builder).append(bean.getContent());
measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
if (measuredText > width) {
sb.clear();
sb.append(builder);
for (int i = 0; i < bean.getContent().length(); i++) {
sb.append(bean.getContent().charAt(i));
measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
if (measuredText + 3 > width) {
bean.setContent(bean.getContent().substring(0, i) + "\n"+ bean.getContent().substring(i));
bean.setContent("");
break;
}
}
}
*/
builder.append(bean.getContent()); builder.append(bean.getContent());
//超皇设置渐变色展示昵称 //超皇设置渐变色展示昵称
if (TextUtils.equals("7", bean.getNobleId()) && !TextUtils.isEmpty(bean.getContentColor())) { if (TextUtils.equals("7", bean.getNobleId()) && !TextUtils.isEmpty(bean.getContentColor())) {
@ -889,7 +965,7 @@ public class LiveTextRender {
if (textView != null) { if (textView != null) {
createPrefix(drawable, bean, new CreatePrefixCallback() { createPrefix(drawable, bean, new CreatePrefixCallback() {
@Override @Override
public void onPrefixCallback(SpannableStringBuilder builder) { public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int start = builder.length(); int start = builder.length();
String name = bean.getUserNiceName() + " "; String name = bean.getUserNiceName() + " ";
builder.append(name); builder.append(name);
@ -906,7 +982,7 @@ public class LiveTextRender {
if (textView != null) { if (textView != null) {
createPrefix(null, bean, new CreatePrefixCallback() { createPrefix(null, bean, new CreatePrefixCallback() {
@Override @Override
public void onPrefixCallback(SpannableStringBuilder builder) { public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int start = builder.length(); int start = builder.length();
String name = bean.getUserNiceName() + " "; String name = bean.getUserNiceName() + " ";
builder.append(name); builder.append(name);

View File

@ -10,7 +10,7 @@
<TextView <TextView
android:id="@+id/text_txt" android:id="@+id/text_txt"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="9dp" android:layout_marginLeft="9dp"
android:layout_marginRight="9dp" android:layout_marginRight="9dp"

View File

@ -5,9 +5,8 @@
<!--左上--> <!--左上-->
<LinearLayout <LinearLayout
android:id="@+id/lin_pk1" android:id="@+id/lin_pk1"
android:layout_width="100dp" android:layout_width="wrap_content"
android:layout_height="100dp" android:layout_height="wrap_content"
android:background="@color/gray1"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone"> android:visibility="gone">
@ -17,7 +16,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5.33dp" android:layout_marginStart="5.33dp"
android:layout_marginTop="4.67dp" android:layout_marginTop="4.67dp"
android:background="@drawable/background_pk_time"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
@ -61,9 +59,8 @@
<!--右上--> <!--右上-->
<LinearLayout <LinearLayout
android:id="@+id/lin_pk2" android:id="@+id/lin_pk2"
android:layout_width="100dp" android:layout_width="wrap_content"
android:layout_height="100dp" android:layout_height="wrap_content"
android:background="@color/red"
android:layout_gravity="end" android:layout_gravity="end"
android:gravity="end" android:gravity="end"
android:orientation="vertical" android:orientation="vertical"

View File

@ -4,7 +4,7 @@ include ':FaceUnity'
//include ':recognizer'// //include ':recognizer'//
include ':Share' include ':Share'
include ':pluginsForAnchor' include ':pluginsForAnchor'
//include ':lib_huawei' include ':lib_huawei'
include ':lib_google' //include ':lib_google'
include ':IAP6Helper' include ':IAP6Helper'
include ':lib_faceunity' include ':lib_faceunity'