diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index 1781132e7..f40261ea2 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -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; } diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveUserAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveUserAdapter.java index 5e5844e82..f9545e55d 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveUserAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveUserAdapter.java @@ -89,8 +89,8 @@ public class LiveUserAdapter extends RecyclerView.Adapter { @Override public int getItemCount() { - if(mList.size()>3) { - return 3; + if(mList.size()>6) { + return 5; }else{ return mList.size(); } diff --git a/live/src/main/java/com/yunbao/live/custom/RightGradual.java b/live/src/main/java/com/yunbao/live/custom/RightGradual.java new file mode 100644 index 000000000..6c47543ed --- /dev/null +++ b/live/src/main/java/com/yunbao/live/custom/RightGradual.java @@ -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); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java index 86cb28ac1..cb62cfc99 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java @@ -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(); } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java index 1a6b253c2..c0426498e 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java @@ -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 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 d285f4f9d..4a9e8efb5 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -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() { @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 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); diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 93258a0a3..57661af73 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -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 list = JSON.parseArray(obj.getString("userlists"), LiveUserGiftBean.class); mLiveRoomViewHolder.setUserList(list); + // resetUserListWidth(list); mLiveRoomViewHolder.startRefreshUserList(); if (mLiveType == Constants.LIVE_TYPE_TIME) {//计时收费 mLiveRoomViewHolder.startRequestTimeCharge(); diff --git a/live/src/main/res/layout/dialog_user_more_list.xml b/live/src/main/res/layout/dialog_user_more_list.xml index 8968196a6..21e4ea6ed 100644 --- a/live/src/main/res/layout/dialog_user_more_list.xml +++ b/live/src/main/res/layout/dialog_user_more_list.xml @@ -16,6 +16,7 @@ android:orientation="vertical"> + + + android:textSize="16sp" + android:visibility="gone" /> diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index 8f54dab3e..172081ad3 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -117,19 +117,27 @@ android:layout_alignParentRight="true" android:orientation="horizontal"> + + android:src="@mipmap/img_guardian_empty" /> + diff --git a/live/src/main/res/mipmap-mdpi/img_guardian_empty.png b/live/src/main/res/mipmap-mdpi/img_guardian_empty.png new file mode 100644 index 000000000..2ce28f05c Binary files /dev/null and b/live/src/main/res/mipmap-mdpi/img_guardian_empty.png differ diff --git a/live/src/main/res/mipmap-mdpi/live_users_more.png b/live/src/main/res/mipmap-mdpi/live_users_more.png index 610ea190a..805bf49b0 100644 Binary files a/live/src/main/res/mipmap-mdpi/live_users_more.png and b/live/src/main/res/mipmap-mdpi/live_users_more.png differ