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 6b8e03168..4b77b27b8 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -35,6 +35,7 @@ import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.formatBigNum; import com.yunbao.live.R; +import com.yunbao.live.bean.GuardUserBean; import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.LiveBuyGuardMsgBean; import com.yunbao.live.bean.LiveChatBean; @@ -86,6 +87,7 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -276,9 +278,9 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL mLiveLinkMicPresenter.onAudienceLeaveRoom(bean); } try { - if (mLiveRoomViewHolder!=null) { + if (mLiveRoomViewHolder != null) { if (!"".equals(bean.getHot_num()) && !"0".equals(bean.getHot_num())) { - // mLiveRoomViewHolder.room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num())); + // mLiveRoomViewHolder.room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num())); mLiveRoomViewHolder.setHotData(formatBigNum.formatBigNum(bean.getHot_num())); } } @@ -331,7 +333,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } - @Override public void onBuyLiangName(LiveReceiveGiftBean bean) { if (mLiveRoomViewHolder != null) { @@ -503,8 +504,8 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } @Override - public void onHourRank(LiveChatBean bean,JSONObject ranks) { - if(mLiveRoomViewHolder!=null){ + public void onHourRank(LiveChatBean bean, JSONObject ranks) { + if (mLiveRoomViewHolder != null) { mLiveRoomViewHolder.setHourRankData(ranks.getInteger(mLiveUid)); } } @@ -1261,17 +1262,30 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL fragment.setArguments(bundle); fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment"); } + /** * 守护列表弹窗 */ public void openNewGuardListWindow() { - LiveNewGuardListDialogFragment fragment = new LiveNewGuardListDialogFragment(); - fragment.setLiveGuardInfo(mLiveGuardInfo); - Bundle bundle = new Bundle(); - bundle.putString(Constants.LIVE_UID, mLiveUid); - bundle.putBoolean(Constants.ANCHOR, mIsAnchor); - fragment.setArguments(bundle); - fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment"); + LiveHttpUtil.getGuardList(mLiveUid, 1, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + List list = JSON.parseArray(Arrays.toString(info), GuardUserBean.class); + if(list.isEmpty()){ + openNewBuyGuardWindow(); + }else { + LiveNewGuardListDialogFragment fragment = new LiveNewGuardListDialogFragment(); + fragment.setList(list); + fragment.setLiveGuardInfo(mLiveGuardInfo); + Bundle bundle = new Bundle(); + bundle.putString(Constants.LIVE_UID, mLiveUid); + bundle.putBoolean(Constants.ANCHOR, mIsAnchor); + fragment.setArguments(bundle); + fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment"); + } + } + }); + } /** @@ -1337,11 +1351,12 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL bundle.putString(Constants.LIVE_UID, mLiveUid); bundle.putString(Constants.LIVE_ANCHER_NAME, mAncherName); bundle.putString(Constants.STREAM, mStream); - bundle.putString(Constants.LIVE_ANCHER_ICON,mAncherIcon); - bundle.putString(Constants.USER_ICON,CommonAppConfig.getInstance().getUserBean().getAvatar()); + bundle.putString(Constants.LIVE_ANCHER_ICON, mAncherIcon); + bundle.putString(Constants.USER_ICON, CommonAppConfig.getInstance().getUserBean().getAvatar()); fragment.setArguments(bundle); fragment.show(getSupportFragmentManager(), "LiveGuardBuyDialogFragment"); } + /** * 打开购买守护的弹窗 */ diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardListDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardListDialogFragment.java index e8dc83c1b..43da6edc3 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardListDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardListDialogFragment.java @@ -34,6 +34,7 @@ import com.yunbao.live.bean.GuardUserBean; import com.yunbao.live.bean.LiveGuardInfo; import com.yunbao.live.http.LiveHttpUtil; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -52,6 +53,7 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements private LiveGuardInfo mLiveGuardInfo; private String mLiveUid; private boolean mIsAnchor;//是否是主播 + private List list=new ArrayList<>(); @Override protected int getLayoutId() { @@ -112,6 +114,9 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements private void initView() { mRefreshView.setEmptyLayoutId(mIsAnchor ? R.layout.view_no_data_guard_anc : R.layout.view_no_data_guard_aud); mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + mGuardAdapter = new GuardAdapter(mContext, true, false); + mGuardAdapter.setList(list); + setAdapterData(); mRefreshView.setDataHelper(new CommonRefreshView.DataHelper() { @Override public RefreshAdapter getAdapter() { @@ -129,36 +134,9 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements @Override public List processData(String[] info) { List list = JSON.parseArray(Arrays.toString(info), GuardUserBean.class); - if (list.isEmpty()) { - userLayout.setVisibility(View.INVISIBLE); - }else { - GuardUserBean bean = list.get(0); - giftSvga.setImageResource(R.drawable.guardian_img_wings_p); - ImgLoader.display(mContext, bean.getAvatar(), guardIcon); - guardIcon.setVisibility(View.VISIBLE); - userName.setText(bean.getUserNiceName()); - String guardString = WordUtil.getString(R.string.guard_week_con); - userGuard.setText(guardString + " " + bean.getContribute()); - userSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex())); - LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel()); - if (levelBean != null) { - ImgLoader.display(mContext, levelBean.getThumb(), userLevel); - } - } - if (mLiveGuardInfo != null) { - int guardType = mLiveGuardInfo.getMyGuardType(); - if (guardType == Constants.GUARD_TYPE_NONE) { - tip1.setText(R.string.guard_tip_0); - } else if (guardType == Constants.GUARD_TYPE_DAY) { - tip1.setText(WordUtil.getString(R.string.guard_tip_day) + mLiveGuardInfo.getMyGuardEndTime()); - mBtnBuy.setText(R.string.guard_buy_3); - } else if (guardType == Constants.GUARD_TYPE_MONTH) { - tip1.setText(WordUtil.getString(R.string.guard_tip_1) + mLiveGuardInfo.getMyGuardEndTime()); - mBtnBuy.setText(R.string.guard_buy_3); - } else if (guardType == Constants.GUARD_TYPE_YEAR) { - tip1.setText(WordUtil.getString(R.string.guard_tip_2) + mLiveGuardInfo.getMyGuardEndTime()); - mBtnBuy.setText(R.string.guard_buy_3); - } + if(!list.isEmpty()){ + LiveNewGuardListDialogFragment.this.list=list; + setAdapterData(); } return list; } @@ -183,7 +161,8 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements } }); - mRefreshView.initData(); + mRefreshView.setRecyclerViewAdapter(mGuardAdapter); + mGuardAdapter.notifyDataSetChanged(); } @Override @@ -198,4 +177,40 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements initView(); return show; } + private void setAdapterData(){ + if (list.isEmpty()) { + userLayout.setVisibility(View.INVISIBLE); + }else { + GuardUserBean bean = list.get(0); + giftSvga.setImageResource(R.drawable.guardian_img_wings_p); + ImgLoader.display(mContext, bean.getAvatar(), guardIcon); + guardIcon.setVisibility(View.VISIBLE); + userName.setText(bean.getUserNiceName()); + String guardString = WordUtil.getString(R.string.guard_week_con); + userGuard.setText(guardString + " " + bean.getContribute()); + userSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex())); + LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel()); + if (levelBean != null) { + ImgLoader.display(mContext, levelBean.getThumb(), userLevel); + } + } + if (mLiveGuardInfo != null) { + int guardType = mLiveGuardInfo.getMyGuardType(); + if (guardType == Constants.GUARD_TYPE_NONE) { + tip1.setText(R.string.guard_tip_0); + } else if (guardType == Constants.GUARD_TYPE_DAY) { + tip1.setText(WordUtil.getString(R.string.guard_tip_day) + mLiveGuardInfo.getMyGuardEndTime()); + mBtnBuy.setText(R.string.guard_buy_3); + } else if (guardType == Constants.GUARD_TYPE_MONTH) { + tip1.setText(WordUtil.getString(R.string.guard_tip_1) + mLiveGuardInfo.getMyGuardEndTime()); + mBtnBuy.setText(R.string.guard_buy_3); + } else if (guardType == Constants.GUARD_TYPE_YEAR) { + tip1.setText(WordUtil.getString(R.string.guard_tip_2) + mLiveGuardInfo.getMyGuardEndTime()); + mBtnBuy.setText(R.string.guard_buy_3); + } + } + } + public void setList(List list) { + this.list=list; + } } diff --git a/live/src/main/res/layout/dialog_new_guard_buy.xml b/live/src/main/res/layout/dialog_new_guard_buy.xml index 9e881af6b..6cbf011f6 100644 --- a/live/src/main/res/layout/dialog_new_guard_buy.xml +++ b/live/src/main/res/layout/dialog_new_guard_buy.xml @@ -245,8 +245,8 @@ android:id="@+id/guard_imageView" android:layout_width="0dp" android:layout_height="58dp" - android:layout_centerHorizontal="true" android:layout_marginTop="30dp" + android:layout_marginStart="125dp" android:scaleType="centerCrop" android:src="@drawable/guardian_img_wings" android:visibility="invisible" @@ -257,7 +257,7 @@ android:layout_width="65dp" android:layout_height="65dp" android:layout_centerHorizontal="true" - android:layout_marginStart="-5dp" + android:layout_marginStart="-6dp" android:layout_marginTop="25dp" android:layout_toEndOf="@+id/guard_imageView" android:scaleType="centerCrop" @@ -269,9 +269,9 @@ android:id="@+id/guard_imageView_one" android:layout_width="65dp" android:layout_height="65dp" - android:layout_centerHorizontal="true" android:layout_marginTop="25dp" - android:layout_toStartOf="@id/guard_imageView" + + android:layout_toStartOf="@id/guard_imageView_two" android:scaleType="centerCrop" android:src="@drawable/guardian_img_wings" android:visibility="invisible" diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index 237e89d32..014378c7b 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -195,8 +195,8 @@