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

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

View File

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