From 8330d7f80899157ce4a8d62ba681ab76441d9cc7 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 10 Aug 2022 18:05:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98,shouye=20ytuijian?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/views/SearchResultsViewHolder.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/com/yunbao/main/views/SearchResultsViewHolder.java b/main/src/main/java/com/yunbao/main/views/SearchResultsViewHolder.java index 5e7d82e09..8d0ed3ffb 100644 --- a/main/src/main/java/com/yunbao/main/views/SearchResultsViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/SearchResultsViewHolder.java @@ -103,9 +103,21 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder { private Spanned userNicenamehighlight(String context, String keyword) { String keywordHtml1 = "" + WordsTypeUtil.changeSimplified(keyword) + ""; - String keywordHtml2 = "" + WordsTypeUtil.changeTraditional(keyword) + ""; - String contextHtml = "" + context + ""; - contextHtml = contextHtml.replace(WordsTypeUtil.changeSimplified(keyword) ,keywordHtml1).replace(WordsTypeUtil.changeTraditional(keyword),keywordHtml2); + //简体 + String simplified = WordsTypeUtil.changeSimplified(keyword); + //繁体 + String traditional = WordsTypeUtil.changeTraditional(keyword); + String contextHtml = ""; + if (TextUtils.equals(simplified, traditional)) { + contextHtml = context.replace(keyword, keywordHtml1); + contextHtml = "" + contextHtml + ""; + } else { + + String keywordHtml2 = "" + WordsTypeUtil.changeTraditional(keyword) + ""; + contextHtml = "" + context + ""; + contextHtml = contextHtml.replace(WordsTypeUtil.changeSimplified(keyword), keywordHtml1).replace(WordsTypeUtil.changeTraditional(keyword), keywordHtml2); + } + return Html.fromHtml(contextHtml); }