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..4832c1d38 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; 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..afd597792 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveUserAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveUserAdapter.java @@ -89,11 +89,7 @@ public class LiveUserAdapter extends RecyclerView.Adapter { @Override public int getItemCount() { - if(mList.size()>3) { - return 3; - }else{ - return mList.size(); - } + return Math.min(mList.size(), 5); } class Vh extends RecyclerView.ViewHolder { 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..01b6ef5e1 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/custom/RightGradual.java @@ -0,0 +1,55 @@ +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 = null; + } + + @Override + public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { + super.onDrawOver(canvas, parent, state); + float left=parent.getRight()-parent.getRight()/0.1f; + float top=0f; + float right=parent.getRight(); + float bottom=parent.getBottom(); + if(mLinearGradient==null){ + mLinearGradient=new LinearGradient(parent.getMeasuredWidth(), 0.0f, 0.0f, 0.0f, new int[]{0, Color.BLACK}, new float[]{0.0f,0.2f}, Shader.TileMode.CLAMP); + } + mPaint.setXfermode(mXfermode); + mPaint.setShader(mLinearGradient); + //mPaint.setColor(Color.BLUE); + 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/LiveUserMoreDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java index 1a6b253c2..eea5cf065 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); @@ -183,14 +189,14 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie Up(); type="dayRank"; mRefreshView.initData(); - no_more.setImageBitmap(null); + no_more.setImageResource(R.drawable.img_rank_empty); }); weekRank.setOnClickListener(View->{ Tips="5"; Up(); type="weekRank"; mRefreshView.initData(); - no_more.setImageBitmap(null); + no_more.setImageResource(R.drawable.img_rank_empty); }); mRefreshView = mRootView.findViewById(R.id.refreshView); @@ -297,12 +303,20 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie bean.setTotal(item.getLong("total")); data.add(bean); } + if(data.size()==0){ + no_more.setVisibility(View.VISIBLE); + }else{ + no_more.setVisibility(View.GONE); + } mRefreshView.setNotLoadMore(); return data; } }); mRefreshView.initData(); - + if(isOnly){ + tabs.setVisibility(View.GONE); + title.setVisibility(View.GONE); + } } @Override @@ -319,6 +333,7 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie void Up() { bottom_msg.setVisibility(View.VISIBLE); + title.setVisibility(View.GONE); if (Tips.equals("1")) { tags.setText("開通貴族,尊享超多特權!"); btn.setBackgroundResource(R.mipmap.btn_openvip); @@ -350,10 +365,14 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie bottom_msg.setVisibility(View.GONE); type="dayRank"; setTextColor(dayRank,audience_btn,guard_btn,fans_btn,gz_view,weekRank); + gz_view.setVisibility(View.GONE); + no_more.setImageResource(R.drawable.img_rank_empty); }else if (Tips.equals("5")){ userMoreInfoAdapter.type = "5"; bottom_msg.setVisibility(View.GONE); type="weekRank"; + gz_view.setVisibility(View.GONE); + no_more.setImageResource(R.drawable.img_rank_empty); setTextColor(weekRank,audience_btn,guard_btn,fans_btn,gz_view,dayRank); } } 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 0e5122ea5..3399f1d06 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -53,6 +53,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; @@ -79,6 +80,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; @@ -98,6 +100,7 @@ import java.lang.ref.WeakReference; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import pl.droidsonroids.gif.GifImageView; @@ -118,6 +121,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis RelativeLayout chat_view; private ImageView mAvatar; private ImageView UserMore; + private RoundedImageView userGuard; private ImageView mLevelAnchor; public static TextView mName; private TextView mID; @@ -213,6 +217,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis static RoundedImageView mic_ico2; static GifImageView dr_pk_end_gif; + private SVGAImageView gift_svga; public static Handler mHandler; private static final int WHAT_PK_TIME = 2;//pk时间变化 what @@ -625,6 +630,8 @@ 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 = (RoundedImageView) findViewById(R.id.user_guard); + gift_svga = (SVGAImageView) findViewById(R.id.gift_svga); 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 +657,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 +723,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); @@ -1098,6 +1107,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); } } @@ -1163,7 +1173,27 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } getIsHot(); + getGuardInfo(); } + private void getGuardInfo(){ + LiveHttpUtil.getUserList(mLiveUid, mStream, "guard", 1, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + JSONObject json=JSONObject.parseObject(info[0]); + JSONArray userlist = json.getJSONArray("userlist"); + if(userlist.size()!=0){ + setGuardIcon(JSONArray.parseArray(userlist.toJSONString(),LiveUserGiftBean.class).get(0)); + } + } + }); + } + private void setGuardIcon(LiveUserGiftBean guard){ + if (guard!=null){ + ImgLoader.displayAvatar(mContext, guard.getAvatar(), userGuard); + gift_svga.setVisibility(View.VISIBLE); + } + } + /** * 守护信息发生变化 @@ -1225,9 +1255,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(); @@ -1236,6 +1266,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); } } @@ -1369,6 +1401,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void refreshUserList(JSONObject obj) { List list = JSON.parseArray(obj.getString("userlist"), LiveUserGiftBean.class); mLiveUserAdapter.refreshList(list); + getGuardInfo(); } /** @@ -1790,6 +1823,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 f8702b73d..d5a4a3b1a 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -36,6 +36,7 @@ import com.yunbao.common.http.HttpCallback; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; 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; @@ -769,7 +770,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onUpUserList(JSONObject obj) { - + mLiveRoomViewHolder.refreshUserList(obj); } @Override @@ -930,6 +931,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/drawable/img_guardian_online.png b/live/src/main/res/drawable/img_guardian_online.png new file mode 100644 index 000000000..fedbcb3ed Binary files /dev/null and b/live/src/main/res/drawable/img_guardian_online.png differ diff --git a/live/src/main/res/drawable/img_rank_empty.png b/live/src/main/res/drawable/img_rank_empty.png new file mode 100644 index 000000000..c7798341d Binary files /dev/null and b/live/src/main/res/drawable/img_rank_empty.png differ 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..0be82513e 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -117,19 +117,49 @@ android:layout_alignParentRight="true" android:orientation="horizontal"> - + + + + + + + + + + + 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