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);