From 4db4fe130190685dd6d30d6bd6dea8ebb9c1951a Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 30 Aug 2022 16:38:12 +0800 Subject: [PATCH] =?UTF-8?q?update:=E8=B0=83=E6=95=B4=E5=AE=88=E6=8A=A4?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=9A=E5=AE=88=E6=8A=A4=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=89=93=E5=BC=80=E8=B4=AD=E4=B9=B0=E5=AE=88?= =?UTF-8?q?=E6=8A=A4=E7=95=8C=E9=9D=A2=20update:=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=AE=88=E6=8A=A4icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/activity/LiveActivity.java | 43 +++++++---- .../LiveNewGuardListDialogFragment.java | 77 +++++++++++-------- .../main/res/layout/dialog_new_guard_buy.xml | 8 +- live/src/main/res/layout/view_live_room.xml | 4 +- 4 files changed, 81 insertions(+), 51 deletions(-) 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 @@