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 f40261ea2..4832c1d38 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -1308,7 +1308,6 @@ 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 f9545e55d..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()>6) { - return 5; - }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/dialog/LiveGuardDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java index cb62cfc99..86cb28ac1 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java @@ -157,8 +157,7 @@ public class LiveGuardDialogFragment extends AbsDialogFragment implements View.O @Override public void onClick(View v) { - System.err.println("点击购买守护2"); - // dismiss(); + dismiss(); ((LiveActivity) mContext).openBuyGuardWindow(); } 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 43471df32..ce08437e5 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -100,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; @@ -120,7 +121,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis RelativeLayout chat_view; private ImageView mAvatar; private ImageView UserMore; - private ImageView userGuard; + private RoundedImageView userGuard; private ImageView mLevelAnchor; public static TextView mName; private TextView mID; @@ -216,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 @@ -628,7 +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 = (ImageView) findViewById(R.id.user_guard); + 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); @@ -1166,7 +1169,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); + } + } + /** * 守护信息发生变化 @@ -1374,6 +1397,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(); } /** 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 f10a491bb..d5a4a3b1a 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -770,7 +770,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onUpUserList(JSONObject obj) { - + mLiveRoomViewHolder.refreshUserList(obj); } @Override 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/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index 172081ad3..0be82513e 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -117,13 +117,35 @@ android:layout_alignParentRight="true" android:orientation="horizontal"> + + + + + + + + + -