From f8c5b072afcb7a3f69e6dc3d96593ab874f4cabf Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 25 Mar 2024 18:05:59 +0800 Subject: [PATCH] =?UTF-8?q?fix=20[=E5=88=86=E4=BA=AB=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E5=92=8C=E5=8A=A8=E6=80=81=E6=94=B9=E6=88=90=E5=8F=AB=E3=80=90?= =?UTF-8?q?=E7=AB=99=E5=86=85=E5=88=86=E4=BA=AB=E3=80=91]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/utils/WordUtil.java | 21 +++++++++++++++- .../PDLiveCustomConversationProvider.java | 25 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/yunbao/common/utils/WordUtil.java b/common/src/main/java/com/yunbao/common/utils/WordUtil.java index 52f6510..657da30 100644 --- a/common/src/main/java/com/yunbao/common/utils/WordUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/WordUtil.java @@ -48,7 +48,26 @@ public class WordUtil { sResources.updateConfiguration(tmp, sResources.getDisplayMetrics()); return str; } - + public static String getChineseString(int res) { + Configuration config = new Configuration(); + Configuration tmp = sResources.getConfiguration(); + config.setToDefaults(); + config.locale = Locale.TRADITIONAL_CHINESE; + sResources.updateConfiguration(config, sResources.getDisplayMetrics()); + String str = sResources.getString(res); + sResources.updateConfiguration(tmp, sResources.getDisplayMetrics()); + return str; + } + public static String getEnglishString(int res) { + Configuration config = new Configuration(); + Configuration tmp = sResources.getConfiguration(); + config.setToDefaults(); + config.locale = Locale.ENGLISH; + sResources.updateConfiguration(config, sResources.getDisplayMetrics()); + String str = sResources.getString(res); + sResources.updateConfiguration(tmp, sResources.getDisplayMetrics()); + return str; + } /** * 是否包含特殊字符 */ diff --git a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java index 2f3ff66..fa7b6fe 100644 --- a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java +++ b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java @@ -1,6 +1,7 @@ package com.yunbao.main.utils; import android.graphics.Color; +import android.text.SpannableString; import android.text.TextUtils; import android.util.Log; import android.view.View; @@ -17,9 +18,11 @@ import com.yunbao.common.utils.DateFormatUtil; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; import com.yunbao.main.R; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Locale; @@ -59,6 +62,28 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider { @Override public void bindViewHolder(ViewHolder holder, BaseUiConversation uiConversation, int position, List list, IViewProviderListener listener) { + List defList = new ArrayList<>(); + defList.add(R.string.rc_conversation_summary_content_image); + defList.add(R.string.rc_conversation_summary_content_voice); + defList.add(R.string.activity_msg_chat_list_card); + for (int def : defList) { + String str = holder.getContext().getString(def); + String cn = WordUtil.getChineseString(def); + String en = WordUtil.getEnglishString(def); + String content = uiConversation.mConversationContent.toString(); + Log.i("列表----", "bindViewHolder: " + str + " | " + uiConversation.mConversationContent); + if (WordUtil.isNewZh()) { + if (en.equals(content)) { + uiConversation.mConversationContent = new SpannableString(WordUtil.getNewString(def)); + break; + } + } else { + if (cn.equals(content)) { + uiConversation.mConversationContent = new SpannableString(WordUtil.getNewString(def)); + break; + } + } + } //根据业务需要,自定义处理 super.bindViewHolder(holder, uiConversation, position, list, listener);