开播小贴士只随机取一条

This commit is contained in:
ningwenqiang 2024-10-11 17:51:07 +08:00
parent 88cf7ca74b
commit 94ec0d1d88
2 changed files with 34 additions and 6 deletions

View File

@ -343,7 +343,13 @@ public class LiveNewReadySwViewHolder extends AbsViewHolder implements View.OnCl
} }
Log.i("LiveOpenTipsBean",data.toString()); Log.i("LiveOpenTipsBean",data.toString());
findViewById(R.id.tips).setVisibility(View.VISIBLE); findViewById(R.id.tips).setVisibility(View.VISIBLE);
for (int i = 0; i < data.size(); i++) { int i = -1;
if (data.size() == 1){
i=0;
}else if (data.size() >1){
i= (int) (Math.random()*data.size());
}
if(i>-1){
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(16), DpUtil.dp2px(16)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(16), DpUtil.dp2px(16));
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
textParams.leftMargin = DpUtil.dp2px(5); textParams.leftMargin = DpUtil.dp2px(5);
@ -356,7 +362,22 @@ public class LiveNewReadySwViewHolder extends AbsViewHolder implements View.OnCl
week.setText(WordUtil.isNewZh() ? data.get(i).getContent() : data.get(i).getEnglish_content()); week.setText(WordUtil.isNewZh() ? data.get(i).getContent() : data.get(i).getEnglish_content());
liveOpenVf.addView(weekView); liveOpenVf.addView(weekView);
} }
liveOpenVf.startFlipping(); //
//
// for (int i = 0; i < data.size(); i++) {
// LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(16), DpUtil.dp2px(16));
// LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// textParams.leftMargin = DpUtil.dp2px(5);
// textParams.rightMargin = DpUtil.dp2px(5);
// params.leftMargin = DpUtil.dp2px(5);
// View weekView = LayoutInflater.from(mContext).inflate(R.layout.view_live_open_tips, null);
// TextView week = weekView.findViewById(R.id.wish_index);
// week.setLayoutParams(textParams);
// week.setGravity(Gravity.CENTER_VERTICAL);
// week.setText(WordUtil.isNewZh() ? data.get(i).getContent() : data.get(i).getEnglish_content());
// liveOpenVf.addView(weekView);
// }
// liveOpenVf.startFlipping();
}else { }else {
findViewById(R.id.tips).setVisibility(View.GONE); findViewById(R.id.tips).setVisibility(View.GONE);
} }

View File

@ -95,17 +95,24 @@
<TextView <TextView
android:id="@+id/cover_text" android:id="@+id/cover_text"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:layout_marginStart="7dp" android:layout_marginStart="3dp"
android:layout_marginEnd="7dp" android:layout_marginEnd="3dp"
android:text="@string/live_cover_2" android:text="@string/live_cover_2"
android:paddingStart="1dp" android:paddingStart="1dp"
android:paddingEnd="1dp" android:paddingEnd="1dp"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:singleLine="true" android:gravity="center"
android:lines="1"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:background="@drawable/bg_chang_live_cover" android:background="@drawable/bg_chang_live_cover"
app:autoSizeMaxTextSize="10sp"
app:autoSizeMinTextSize="8sp"
app:autoSizeStepGranularity="1sp"
app:autoSizeTextType="uniform"
android:textSize="10sp" android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"