From ee53edbe1cd7c3879f7737ece8b1f2f3ad126e04 Mon Sep 17 00:00:00 2001 From: Martin <13046765170@163.com> Date: Wed, 9 Oct 2024 13:49:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=9B=B4=E6=92=AD=E9=97=B4pu?= =?UTF-8?q?sh=20View=E9=80=9A=E7=9F=A5UI=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/views/LiveRoomViewHolder.java | 65 ++++++++++--------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 1f0c6c6e4..9e2ccdbbf 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -958,9 +958,18 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis private void setTrickyMsg() { if (tricky_layout_name != null) { tricky_layout_name.setVisibility(View.VISIBLE); + tricky_layout_name.post(new Runnable() { + @Override + public void run() { + ViewGroup.LayoutParams params1 = tricky_layout_name.getLayoutParams(); + params1.width = mChatRecyclerView.getWidth()-DpUtil.dp2px(5); + tricky_layout_name.setLayoutParams(params1); + } + }); } sudNameHandler.removeCallbacks(trickyRunnable); sudNameHandler.postDelayed(trickyRunnable, 10000); + } public void setSudName(String sudName, SudGameDateModel sudGameDateModel) { @@ -1000,15 +1009,15 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis }); sudNameHandler.removeCallbacks(sudNameRunnable); sudNameHandler.postDelayed(sudNameRunnable, 10000); -// sud_layout_name.post(new Runnable() { -// @Override -// public void run() { -// //TODO 这里报了类型错误 android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams -//// ViewGroup.LayoutParams params1 = sud_layout_name.getLayoutParams(); -//// params1.width = mChatRecyclerView.getWidth() - DpUtil.dp2px(85); -//// sud_layout_name.setLayoutParams(params1); -// } -// }); + sud_layout_name.post(new Runnable() { + @Override + public void run() { + //TODO 这里报了类型错误 android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams + ViewGroup.LayoutParams params1 = sud_layout_name.getLayoutParams(); + params1.width = mChatRecyclerView.getWidth()-DpUtil.dp2px(5); + sud_layout_name.setLayoutParams(params1); + } + }); new Handler().postDelayed(new Runnable() { @Override @@ -1049,7 +1058,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis @Override public void run() { LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams) notify_follow_layout.getLayoutParams(); - params1.width = mChatRecyclerView.getWidth() - DpUtil.dp2px(72); + params1.width = mChatRecyclerView.getWidth(); notify_follow_layout.setLayoutParams(params1); } }); @@ -1119,7 +1128,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis @Override public void run() { LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams) new_task_gift_notify.getLayoutParams(); - params1.width = mChatRecyclerView.getWidth() - DpUtil.dp2px(72); + params1.width = mChatRecyclerView.getWidth(); new_task_gift_notify.setLayoutParams(params1); } }); @@ -1178,7 +1187,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis @Override public void run() { LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams) new_task_gift_notify1.getLayoutParams(); - params1.width = mChatRecyclerView.getWidth() - DpUtil.dp2px(72); + params1.width = mChatRecyclerView.getWidth(); new_task_gift_notify1.setLayoutParams(params1); } }); @@ -1239,7 +1248,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis @Override public void run() { LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams) new_task_send_gift_notify.getLayoutParams(); - params1.width = mChatRecyclerView.getWidth() - DpUtil.dp2px(72); + params1.width = mChatRecyclerView.getWidth(); new_task_send_gift_notify.setLayoutParams(params1); } }); @@ -1288,7 +1297,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void showH5Dialog() { Bundle bundle = new Bundle(); - bundle.putString("url", CommonAppConfig.HOST + "/h5/activity/pdlNewUes/index.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+"&app_from=PDL"); + bundle.putString("url", CommonAppConfig.HOST + "/h5/activity/pdlNewUes/index.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&app_from=PDL"); LiveHDDialogFragment fragment = new LiveHDDialogFragment(); fragment.setArguments(bundle); fragment.show(((LiveActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); @@ -1969,7 +1978,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis params1.topMargin = DpUtil.dp2px(65); params1.bottomMargin = 0; mChatRecyclerView.setLayoutParams(params1); - }else { + } else { params1.topMargin = DpUtil.dp2px(80); } mChatRecyclerView.setLayoutParams(params1); @@ -2252,10 +2261,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis ((LiveActivity) mContext).sendChatMessage(msg, null, null); fastMsgRecyclerView.setVisibility(View.GONE); RelativeLayout.LayoutParams params4 = (RelativeLayout.LayoutParams) live_bottom_layout.getLayoutParams(); - if(isAnchorLive()){ + if (isAnchorLive()) { params1.bottomMargin = 0; params4.bottomMargin = 0; - }else { + } else { params1.bottomMargin = DpUtil.dp2px(10); params4.bottomMargin = DpUtil.dp2px(10); } @@ -2285,9 +2294,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis }); // mBanner2.setVisibility(View.GONE); if (fastMsgRecyclerView.getVisibility() == View.GONE) { - if (isAnchorLive()){ - params1.bottomMargin =0; - }else { + if (isAnchorLive()) { + params1.bottomMargin = 0; + } else { params1.bottomMargin = DpUtil.dp2px(10); } mChatRecyclerView.setLayoutParams(params1); @@ -3480,8 +3489,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * @param view 要添加到翻转动画器的视图 */ private void startNewPart2Flipper(View view) { - if (view == null) - return; + if (view == null) return; if (newPart2Flipper.getVisibility() != View.VISIBLE) { newPart2Flipper.setVisibility(View.VISIBLE); } @@ -3506,8 +3514,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * @param view 要从翻页器中移除的视图 */ private void stopPart2Flipper(View view) { - if (view == null) - return; + if (view == null) return; // 获取翻页器中当前的子视图数量,以判断是否满足停止翻页的条件 newPart2Flipper.getChildCount(); @@ -4068,13 +4075,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis int mScreenWdith = util.getScreenWdith(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams(); if (isAnchorLive()) {//因为主播的比较短所以往上移动 - // params.setMargins(0, 0, DpUtil.dp2px(R.dimen.live_top), 0); + // params.setMargins(0, 0, DpUtil.dp2px(R.dimen.live_top), 0); } params.height = mScreenWdith * 720 / PK_LINE_HEIGHT; - if(isAnchorLive()){ + if (isAnchorLive()) { //280来自:view_live_play_sw.xml的pk_container高度 //42来自:view_live_room.xml的pk_red_layout的头像框高度 - params.height= DpUtil.dp2px(280-42); + params.height = DpUtil.dp2px(280 - 42); } //params.bottomMargin=(mScreenWdith * 720 / 960); lt_pk_line.requestLayout(); @@ -5656,10 +5663,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis if (greetings.size() > 0) { params1.bottomMargin = DpUtil.dp2px(38); params2.bottomMargin = DpUtil.dp2px(38); - } else if(isAnchorLive()){ + } else if (isAnchorLive()) { params1.bottomMargin = 0; params2.bottomMargin = 0; - }else { + } else { params1.bottomMargin = DpUtil.dp2px(10); params2.bottomMargin = DpUtil.dp2px(10); }