dev:观众滑动透明效果

This commit is contained in:
zlzw 2022-08-23 11:30:08 +08:00
parent 318a3dcf8c
commit 2a5814f2fc
12 changed files with 106 additions and 14 deletions

View File

@ -1278,13 +1278,14 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
/**
* 打开观看列表弹窗
*/
public void openUserMoreListWindow(int i) {
public void openUserMoreListWindow(int i,boolean isOnly) {
LiveUserMoreDialogFragment fragment = new LiveUserMoreDialogFragment();
fragment.setLiveGuardInfo(mLiveGuardInfo);
Bundle bundle = new Bundle();
bundle.putString(Constants.LIVE_UID, mLiveUid);
bundle.putString(Constants.STREAM, mStream);
bundle.putString("By", i + "");
bundle.putBoolean("only",isOnly);
fragment.setArguments(bundle);
fragment.show(getSupportFragmentManager(), "LiveUserMoreDialogFragment");
LiveUserMoreDialogFragment.activity = this;
@ -1307,6 +1308,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 打开购买守护的弹窗
*/
public void openBuyGuardWindow() {
System.out.println("点击购买守护 > "+TextUtils.isEmpty(mLiveUid)+" "+TextUtils.isEmpty(mStream)+" "+mLiveGuardInfo);
if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream) || mLiveGuardInfo == null) {
return;
}

View File

@ -89,8 +89,8 @@ public class LiveUserAdapter extends RecyclerView.Adapter<LiveUserAdapter.Vh> {
@Override
public int getItemCount() {
if(mList.size()>3) {
return 3;
if(mList.size()>6) {
return 5;
}else{
return mList.size();
}

View File

@ -0,0 +1,53 @@
package com.yunbao.live.custom;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Shader;
import android.graphics.Xfermode;
import androidx.recyclerview.widget.RecyclerView;
/**
* Created by cxf on 2018/1/27.
* RecyclerView右側渐变的itemDecoration
*/
public class RightGradual extends RecyclerView.ItemDecoration {
private Paint mPaint;
private Xfermode mXfermode;
private LinearGradient mLinearGradient;
private int mLayerId;
public RightGradual() {
mPaint = new Paint();
mXfermode = new PorterDuffXfermode(PorterDuff.Mode.DST_IN);
mLinearGradient = new LinearGradient(0.0f, 0.0f, 0.0f, 10.0f, new int[]{0, Color.BLACK}, null, Shader.TileMode.CLAMP);
}
@Override
public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
super.onDrawOver(canvas, parent, state);
float left=parent.getRight()-parent.getRight()/2f;
float top=0f;
float right=parent.getRight();
float bottom=parent.getBottom();
mPaint.setXfermode(mXfermode);
mPaint.setShader(mLinearGradient);
//mPaint.setColor(Color.BLUE);
System.out.println("left = "+left+" right = "+right+" bottom = "+bottom);
canvas.drawRect(left, top,right, bottom, mPaint);
mPaint.setXfermode(null);
canvas.restoreToCount(mLayerId);
}
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
super.onDraw(c, parent, state);
mLayerId = c.saveLayer(0.0f, 0.0f, (float) parent.getWidth(), (float) parent.getHeight(), mPaint, Canvas.ALL_SAVE_FLAG);
}
}

View File

@ -157,7 +157,8 @@ public class LiveGuardDialogFragment extends AbsDialogFragment implements View.O
@Override
public void onClick(View v) {
dismiss();
System.err.println("点击购买守护2");
// dismiss();
((LiveActivity) mContext).openBuyGuardWindow();
}

View File

@ -9,6 +9,7 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
@ -55,10 +56,12 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie
public static LiveActivity activity = null;
public eightbitlab.com.blurview.BlurView blurView;
public TextView audience_btn, guard_btn, fans_btn, tags, btn, gz_view, dayRank, weekRank;
public TextView audience_btn, guard_btn, fans_btn, tags, btn, gz_view, dayRank, weekRank,title;
private LinearLayout tabs;
private RelativeLayout bottom_msg;//底部信息的布局在榜单列表下不需要显示底部信息
private String Tips = "1";
private String type = "guanzhong";
private boolean isOnly;
ImageView no_more;
@Override
@ -120,6 +123,9 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie
mLiveUid = bundle.getString(Constants.LIVE_UID);
stream = bundle.getString(Constants.STREAM);
isOnly = bundle.getBoolean("only",false);
title = mRootView.findViewById(R.id.title);
tabs = mRootView.findViewById(R.id.tabs);
audience_btn = mRootView.findViewById(R.id.audience_btn);
bottom_msg = mRootView.findViewById(R.id.bottom_msg);
tags = mRootView.findViewById(R.id.tag);
@ -302,7 +308,10 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie
}
});
mRefreshView.initData();
if(isOnly){
tabs.setVisibility(View.GONE);
title.setVisibility(View.GONE);
}
}
@Override

View File

@ -54,6 +54,7 @@ import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.common.utils.StringUtil;
@ -80,6 +81,7 @@ import com.yunbao.live.bean.LiveReceiveGiftBean;
import com.yunbao.live.bean.LiveUserGiftBean;
import com.yunbao.live.bean.WishlistItemModel;
import com.yunbao.live.custom.LiveLightView;
import com.yunbao.live.custom.RightGradual;
import com.yunbao.live.custom.TopGradual;
import com.yunbao.live.dialog.LiveFansMedalDialogFragment;
import com.yunbao.live.dialog.LiveHDDialogFragment;
@ -118,6 +120,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
RelativeLayout chat_view;
private ImageView mAvatar;
private ImageView UserMore;
private ImageView userGuard;
private ImageView mLevelAnchor;
public static TextView mName;
private TextView mID;
@ -625,6 +628,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mTvMedalRank = (TextView) findViewById(R.id.medal_rank_num);
mGuardNum = (TextView) findViewById(R.id.guard_num);
UserMore = (ImageView) findViewById(R.id.user_more);
userGuard = (ImageView) findViewById(R.id.user_guard);
tv_avatarOther_name = (TextView) findViewById(R.id.tv_avatarOther_name);
room_hot = (TextView) findViewById(R.id.room_hot);
fans = (TextView) findViewById(R.id.fans);
@ -650,6 +654,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mUserRecyclerView = (RecyclerView) findViewById(R.id.user_recyclerView);
mUserRecyclerView.setHasFixedSize(true);
mUserRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
mUserRecyclerView.addItemDecoration(new RightGradual());
mLiveUserAdapter = new LiveUserAdapter(mContext);
mLiveUserAdapter.setOnItemClickListener(new OnItemClickListener<UserBean>() {
@Override
@ -715,6 +720,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
findViewById(R.id.btn_medal_rank).setOnClickListener(this);
findViewById(R.id.btn_noble).setOnClickListener(this);
UserMore.setOnClickListener(this);
userGuard.setOnClickListener(this);
findViewById(R.id.btn_guard).setOnClickListener(this);
mBtnPrizePool = findViewById(R.id.btn_prize_pool_level);
@ -1094,6 +1100,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
*/
public void setUserList(List<LiveUserGiftBean> list) {
if (mLiveUserAdapter != null) {
resetUserListWidth(DpUtil.dp2px((Math.min(list.size(), 3))*38));
mLiveUserAdapter.refreshList(list);
}
}
@ -1221,9 +1228,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} else if (i == R.id.btn_prize_pool_level) {
((LiveActivity) mContext).openPrizePoolWindow();
} else if (i == R.id.user_more) {
((LiveActivity) mContext).openUserMoreListWindow(4);
((LiveActivity) mContext).openUserMoreListWindow(4,false);
} else if (i == R.id.hot_btn) {
((LiveActivity) mContext).openUserMoreListWindow(1);
((LiveActivity) mContext).openUserMoreListWindow(1,false);
} else if (i == R.id.btn_close) {
close();
@ -1232,6 +1239,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
((LiveActivity) mContext).openLuckGiftTip();
} else if (i == R.id.ft_hot_add) {
((LiveActivity) mContext).openHotListWindow(1);
} else if (i == R.id.user_guard){
((LiveActivity) mContext).openUserMoreListWindow(2,true);
}
}
@ -1786,6 +1795,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
});
}
public void resetUserListWidth(int width){
ViewGroup.LayoutParams params = mUserRecyclerView.getLayoutParams();
params.width=width;
mUserRecyclerView.setLayoutParams(params);
}
public void release() {
LiveHttpUtil.cancel(LiveHttpConsts.GET_USER_LIST);

View File

@ -48,6 +48,7 @@ import com.yunbao.common.http.main.MainNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.RandomUtil;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
@ -1012,6 +1013,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
List<LiveUserGiftBean> list = JSON.parseArray(obj.getString("userlists"), LiveUserGiftBean.class);
mLiveRoomViewHolder.setUserList(list);
// resetUserListWidth(list);
mLiveRoomViewHolder.startRefreshUserList();
if (mLiveType == Constants.LIVE_TYPE_TIME) {//计时收费
mLiveRoomViewHolder.startRequestTimeCharge();

View File

@ -16,6 +16,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
@ -26,11 +27,13 @@
android:textSize="18sp" />
<LinearLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="24dp"
android:orientation="horizontal">
<TextView
android:id="@+id/day_rank_btn"
android:layout_width="wrap_content"
@ -40,6 +43,7 @@
android:text="@string/day_rank"
android:textColor="#fff6f7fb"
android:textSize="16sp" />
<TextView
android:id="@+id/week_rank_btn"
android:layout_width="wrap_content"
@ -66,10 +70,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:visibility="gone"
android:text="@string/live_guard"
android:textColor="#ff646464"
android:textSize="16sp" />
android:textSize="16sp"
android:visibility="gone" />
<TextView
android:id="@+id/fans_btn"

View File

@ -3,7 +3,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="38dp"
android:layout_marginLeft="8dp"
android:layout_height="wrap_content"
>

View File

@ -117,19 +117,27 @@
android:layout_alignParentRight="true"
android:orientation="horizontal">
<ImageView
android:id="@+id/user_more"
android:id="@+id/user_guard"
android:layout_width="33dp"
android:layout_height="33dp"
android:layout_marginTop="4dp"
android:src="@mipmap/live_users_more" />
android:src="@mipmap/img_guardian_empty" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/user_recyclerView"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginRight="40dp"
android:layout_marginRight="-3dp"
android:overScrollMode="never" />
<ImageView
android:id="@+id/user_more"
android:layout_width="33dp"
android:layout_height="33dp"
android:layout_marginTop="4dp"
android:layout_marginRight="40dp"
android:src="@mipmap/live_users_more" />
</LinearLayout>
</RelativeLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB