直播间聊天列表动态改变高度

This commit is contained in:
18401019693 2022-08-30 14:50:21 +08:00
parent 81cafdf995
commit 7155ed9884
2 changed files with 56 additions and 40 deletions

View File

@ -867,8 +867,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
//点击的消息发送出去 //点击的消息发送出去
((LiveActivity) mContext).sendChatMessage(msg); ((LiveActivity) mContext).sendChatMessage(msg);
fastMsgRecyclerView.setVisibility(View.GONE); fastMsgRecyclerView.setVisibility(View.GONE);
params1.bottomMargin = 0;
mChatRecyclerView.setLayoutParams(params1);
}); });
// fastMsgRecyclerView.setItemAnimator(new DefaultItemAnimator());
// fastMsgRecyclerView.setItemAnimator(new DefaultItemAnimator());
} }
private void showBanner2() { private void showBanner2() {
@ -1067,24 +1071,25 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
wishListFlipper.startFlipping(); wishListFlipper.startFlipping();
}); });
} }
/** /**
* 初始化小时榜 * 初始化小时榜
*/ */
protected void initHourRankList(){ protected void initHourRankList() {
ViewFlipper flipper= (ViewFlipper) findViewById(R.id.hour_rank_list); ViewFlipper flipper = (ViewFlipper) findViewById(R.id.hour_rank_list);
LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(DpUtil.dp2px(44),DpUtil.dp2px(16)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(44), DpUtil.dp2px(16));
API.get().pdLiveApi(mContext).getHourChartRank(mLiveUid) API.get().pdLiveApi(mContext).getHourChartRank(mLiveUid)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> { .subscribe(listResponseModel -> {
List<HourRank> info = listResponseModel.getData().getInfo(); List<HourRank> info = listResponseModel.getData().getInfo();
if(!info.isEmpty()){ if (!info.isEmpty()) {
View hotView=LayoutInflater.from(mContext).inflate(R.layout.view_wish_list,null); View hotView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
View hourView=LayoutInflater.from(mContext).inflate(R.layout.view_wish_list,null); View hourView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
ImageView hotPic = hotView.findViewById(R.id.wish_pic); ImageView hotPic = hotView.findViewById(R.id.wish_pic);
ImageView hourPic = hourView.findViewById(R.id.wish_pic); ImageView hourPic = hourView.findViewById(R.id.wish_pic);
mHotText =hotView.findViewById(R.id.wish_index); mHotText = hotView.findViewById(R.id.wish_index);
mHourRank=hourView.findViewById(R.id.wish_index); mHourRank = hourView.findViewById(R.id.wish_index);
setHourRankData(info.get(0).getRank()); setHourRankData(info.get(0).getRank());
hotPic.setImageResource(R.drawable.live_tags_hot); hotPic.setImageResource(R.drawable.live_tags_hot);
@ -1095,17 +1100,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
flipper.addView(hourView); flipper.addView(hourView);
flipper.setOnClickListener(view -> { flipper.setOnClickListener(view -> {
Bundle bundle=new Bundle(); Bundle bundle = new Bundle();
String path=info.get(0).getUrl(); String path = info.get(0).getUrl();
if(!path.startsWith("/")){ if (!path.startsWith("/")) {
path="/"+path; path = "/" + path;
} }
String url=CommonAppConfig.HOST+path; String url = CommonAppConfig.HOST + path;
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
+ CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid;
System.out.println("url = " + url); System.out.println("url = " + url);
bundle.putString("url", url); bundle.putString("url", url);
// bundle.putInt("height", DpUtil.dp2px(500)); // bundle.putInt("height", DpUtil.dp2px(500));
bundle.putInt("show_type", 0); bundle.putInt("show_type", 0);
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment(); LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
liveHDDialogFragment.setArguments(bundle); liveHDDialogFragment.setArguments(bundle);
@ -1119,27 +1124,29 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
/** /**
* 星光值转带k的字符 * 星光值转带k的字符
*
* @param val * @param val
* @retur 字符串 * @retur 字符串
*/ */
private String starlightValToString(long val){ private String starlightValToString(long val) {
if(val>1000) { if (val > 1000) {
double tmp =(double)val / 1000; double tmp = (double) val / 1000;
return tmp + "k"; return tmp + "k";
}else{ } else {
return val+""; return val + "";
} }
} }
/** /**
* 设置小时榜 * 设置小时榜
*
* @param rank 小时榜 * @param rank 小时榜
*/ */
public void setHourRankData(long rank){ public void setHourRankData(long rank) {
if(mHourRank!=null) { if (mHourRank != null) {
if(rank==0){ if (rank == 0) {
mHourRank.setText(R.string.no_rank_data); mHourRank.setText(R.string.no_rank_data);
}else { } else {
mHourRank.setText(formatBigNum.formatBigNum(rank + "")); mHourRank.setText(formatBigNum.formatBigNum(rank + ""));
} }
} }
@ -1147,14 +1154,16 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
/** /**
* 设置热度值 * 设置热度值
*
* @param hot 热度值 * @param hot 热度值
*/ */
public void setHotData(String hot){ public void setHotData(String hot) {
if(mHotText!=null) { if (mHotText != null) {
mHotText.setText(hot); mHotText.setText(hot);
} }
} }
/** /**
* 更新心愿单进度 * 更新心愿单进度
* *
@ -1604,7 +1613,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} else if (i == R.id.ft_hot_add) { } else if (i == R.id.ft_hot_add) {
((LiveActivity) mContext).openHotListWindow(1); ((LiveActivity) mContext).openHotListWindow(1);
} else if (i == R.id.user_guard) { } else if (i == R.id.user_guard) {
// ((LiveActivity) mContext).openUserMoreListWindow(2, true); // ((LiveActivity) mContext).openUserMoreListWindow(2, true);
((LiveActivity) mContext).openNewGuardListWindow(); ((LiveActivity) mContext).openNewGuardListWindow();
} }
@ -2296,7 +2305,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} }
public void setFastMessage(List<String> greetings) { public void setFastMessage(List<String> greetings) {
fastMsgRecyclerView.setVisibility(View.VISIBLE);
fastMessageRecyclerViewAdapter.setMessage(greetings); fastMessageRecyclerViewAdapter.setMessage(greetings);
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
mChatRecyclerView.getLayoutParams();
params1.bottomMargin = 100;
mChatRecyclerView.setLayoutParams(params1);
} }
private static class LiveRoomHandler extends Handler { private static class LiveRoomHandler extends Handler {

View File

@ -244,6 +244,7 @@
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:padding="3dp" android:padding="3dp"
android:src="@mipmap/icon_live_close_3" /> android:src="@mipmap/icon_live_close_3" />
<LinearLayout <LinearLayout
android:id="@+id/hour_rank_layout" android:id="@+id/hour_rank_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -260,26 +261,27 @@
<include <include
layout="@layout/view_wish_list" layout="@layout/view_wish_list"
android:layout_width="14dp" android:layout_width="14dp"
android:layout_weight="0.0"
android:layout_height="14dp" android:layout_height="14dp"
android:visibility="gone" android:layout_weight="0.0"
android:src="@mipmap/live_icon_wishlist" /> android:src="@mipmap/live_icon_wishlist"
android:visibility="gone" />
<ViewFlipper <ViewFlipper
android:id="@+id/hour_rank_list" android:id="@+id/hour_rank_list"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_marginStart="-2dp" android:layout_marginStart="-2dp"
android:layout_marginEnd="6dp"
android:layout_weight="2" android:layout_weight="2"
android:flipInterval="5000" android:flipInterval="5000"
android:layout_marginEnd="6dp"
android:inAnimation="@anim/anim_marquee_in" android:inAnimation="@anim/anim_marquee_in"
android:outAnimation="@anim/anim_marquee_out"/> android:outAnimation="@anim/anim_marquee_out" />
<ImageView <ImageView
android:layout_width="4dp" android:layout_width="4dp"
android:layout_gravity="center"
android:layout_height="8dp" android:layout_height="8dp"
android:layout_gravity="center"
android:src="@drawable/live_icon_right_more" /> android:src="@drawable/live_icon_right_more" />
@ -287,18 +289,18 @@
<!--贡献--> <!--贡献-->
<LinearLayout <LinearLayout
android:id="@+id/btn_votes" android:id="@+id/btn_votes"
android:layout_toRightOf="@id/hour_rank_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="21dp" android:layout_height="21dp"
android:layout_below="@id/lin" android:layout_below="@id/lin"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_toRightOf="@id/hour_rank_layout"
android:background="@drawable/bg_live_item" android:background="@drawable/bg_live_item"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="5dp"> android:paddingRight="5dp"
android:visibility="gone">
<ImageView <ImageView
android:layout_width="13dp" android:layout_width="13dp"
@ -712,14 +714,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginRight="80dp" android:layout_marginRight="80dp"
android:layout_marginBottom="50dp"
android:gravity="top" android:gravity="top"
android:orientation="vertical"> android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/chat_recyclerView" android:id="@+id/chat_recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginTop="430dp" android:layout_marginTop="430dp"
android:overScrollMode="never" android:overScrollMode="never"
android:scrollbars="none" /> android:scrollbars="none" />
@ -1868,7 +1869,8 @@
android:id="@+id/room_fast_msg" android:id="@+id/room_fast_msg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_alignParentBottom="true" /> android:layout_alignParentBottom="true"
android:visibility="gone" />
</RelativeLayout> </RelativeLayout>