From 5b4912815a58cfb6efd7f4b3d3ad2d7ff56f0fe6 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 12 Oct 2022 10:05:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BAIm=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/main/res/values/strings.xml | 1 + .../com/yunbao/live/utils/LiveTextRender.java | 28 +++++++++++++++---- .../yunbao/live/views/CustomViewHolder.java | 2 ++ live/src/main/res/layout/view_start_level.xml | 15 +++++----- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 8210d5524..a0061ff5d 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -923,6 +923,7 @@ 無法@自己 總星值 助力人數 + 星级挑战%s diff --git a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java index 85698994e..755170000 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java @@ -108,7 +108,7 @@ public class LiveTextRender { spannableStringBuilder.append(" "); spannableStringBuilder.append(content); spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor(nameColor)), - 4, 4+aiName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + 4, 4 + aiName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); if (!TextUtils.isEmpty(userName) && !userName.contains(",")) { String mContext = content; userName = "@" + userName; @@ -122,13 +122,29 @@ public class LiveTextRender { mContext = mContext.substring(end + 1, mContext.length()); startIndex = startIndex + end + 1; } + } else { + String[] userNames = userName.split(","); + int startIndex = 6 + aiName.length(); + String mContext = content; + for (String name : userNames) { + name = "@" + name; + while (mContext.contains(name)&&!TextUtils.isEmpty(mContext)) { + int index = mContext.indexOf(name); + int end = index + name.length(); + int endIndex = startIndex + name.length(); + spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#fffe9b")), + startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + mContext = mContext.substring(end + 1, mContext.length()); + startIndex = startIndex + end + 1; + } + } - drawable.setBounds(0, 0, DpUtil.dp2px(39), DpUtil.dp2px(15)); - //用这个drawable对象代替字符串easy - ImageSpan span = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE); - spannableStringBuilder.setSpan(span, 0, 3, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); - textView.setText(spannableStringBuilder); } + drawable.setBounds(0, 0, DpUtil.dp2px(39), DpUtil.dp2px(15)); + //用这个drawable对象代替字符串easy + ImageSpan span = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE); + spannableStringBuilder.setSpan(span, 0, 3, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); + textView.setText(spannableStringBuilder); } @Override diff --git a/live/src/main/java/com/yunbao/live/views/CustomViewHolder.java b/live/src/main/java/com/yunbao/live/views/CustomViewHolder.java index f36ad600d..766aef76d 100644 --- a/live/src/main/java/com/yunbao/live/views/CustomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/CustomViewHolder.java @@ -35,6 +35,7 @@ public class CustomViewHolder implements BannerViewHolder { TextView numberOfPeopleAssisted = contextView.findViewById(R.id.number_of_people_assisted); TextView targetAssist = contextView.findViewById(R.id.target_assist_num); TextView currentAssist = contextView.findViewById(R.id.current_assist_num); + TextView title = contextView.findViewById(R.id.title); if (data.isStart()) { startContext.setVisibility(View.VISIBLE); Glide.with(context).load(R.mipmap.start_level).into(bannerBack); @@ -60,6 +61,7 @@ public class CustomViewHolder implements BannerViewHolder { numberOfPeopleAssisted.setText(TextUtils.isEmpty(data.getModel().getTaskName2()) ? context.getString(R.string.total_star_value) : data.getModel().getTaskName2()); targetAssist.setText("/" + targetAssistNum); currentAssist.setText(String.valueOf(currentAssistNum)); + title.setText(String.format(context.getString(R.string.star_change),data.getModel().getTaskNum())); } else { String imagerUrl = data.getImageUrl().replace("qny", "downs"); Glide.with(context).load(imagerUrl).into(bannerBack); diff --git a/live/src/main/res/layout/view_start_level.xml b/live/src/main/res/layout/view_start_level.xml index f2a95ba8a..0edc13017 100644 --- a/live/src/main/res/layout/view_start_level.xml +++ b/live/src/main/res/layout/view_start_level.xml @@ -17,13 +17,14 @@ android:layout_marginBottom="10dp"> + android:textSize="7sp" /> + android:textSize="6.5sp" /> + android:textSize="6.5dp" /> + android:textSize="6.5dp" /> @@ -110,7 +111,7 @@ android:layout_height="wrap_content" android:text="@string/number_of_people_assisted" android:textColor="#C53F4E" - android:textSize="5.33sp" /> + android:textSize="6.5sp" /> + android:textSize="6.5dp" /> + android:textSize="6.5dp" />