update:调整守护逻辑:守护列表为空的情况下,直接打开购买守护界面

update:调整守护icon
This commit is contained in:
zlzw 2022-08-30 16:38:12 +08:00
parent f27e21b9ae
commit 4db4fe1301
4 changed files with 81 additions and 51 deletions

View File

@ -35,6 +35,7 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.utils.formatBigNum; import com.yunbao.common.utils.formatBigNum;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.bean.GuardUserBean;
import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.LiveBean;
import com.yunbao.live.bean.LiveBuyGuardMsgBean; import com.yunbao.live.bean.LiveBuyGuardMsgBean;
import com.yunbao.live.bean.LiveChatBean; import com.yunbao.live.bean.LiveChatBean;
@ -86,6 +87,7 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -276,9 +278,9 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
mLiveLinkMicPresenter.onAudienceLeaveRoom(bean); mLiveLinkMicPresenter.onAudienceLeaveRoom(bean);
} }
try { try {
if (mLiveRoomViewHolder!=null) { if (mLiveRoomViewHolder != null) {
if (!"".equals(bean.getHot_num()) && !"0".equals(bean.getHot_num())) { 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())); mLiveRoomViewHolder.setHotData(formatBigNum.formatBigNum(bean.getHot_num()));
} }
} }
@ -331,7 +333,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
} }
@Override @Override
public void onBuyLiangName(LiveReceiveGiftBean bean) { public void onBuyLiangName(LiveReceiveGiftBean bean) {
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
@ -503,8 +504,8 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
} }
@Override @Override
public void onHourRank(LiveChatBean bean,JSONObject ranks) { public void onHourRank(LiveChatBean bean, JSONObject ranks) {
if(mLiveRoomViewHolder!=null){ if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.setHourRankData(ranks.getInteger(mLiveUid)); mLiveRoomViewHolder.setHourRankData(ranks.getInteger(mLiveUid));
} }
} }
@ -1261,17 +1262,30 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
fragment.setArguments(bundle); fragment.setArguments(bundle);
fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment"); fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment");
} }
/** /**
* 守护列表弹窗 * 守护列表弹窗
*/ */
public void openNewGuardListWindow() { public void openNewGuardListWindow() {
LiveNewGuardListDialogFragment fragment = new LiveNewGuardListDialogFragment(); LiveHttpUtil.getGuardList(mLiveUid, 1, new HttpCallback() {
fragment.setLiveGuardInfo(mLiveGuardInfo); @Override
Bundle bundle = new Bundle(); public void onSuccess(int code, String msg, String[] info) {
bundle.putString(Constants.LIVE_UID, mLiveUid); List<GuardUserBean> list = JSON.parseArray(Arrays.toString(info), GuardUserBean.class);
bundle.putBoolean(Constants.ANCHOR, mIsAnchor); if(list.isEmpty()){
fragment.setArguments(bundle); openNewBuyGuardWindow();
fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment"); }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_UID, mLiveUid);
bundle.putString(Constants.LIVE_ANCHER_NAME, mAncherName); bundle.putString(Constants.LIVE_ANCHER_NAME, mAncherName);
bundle.putString(Constants.STREAM, mStream); bundle.putString(Constants.STREAM, mStream);
bundle.putString(Constants.LIVE_ANCHER_ICON,mAncherIcon); bundle.putString(Constants.LIVE_ANCHER_ICON, mAncherIcon);
bundle.putString(Constants.USER_ICON,CommonAppConfig.getInstance().getUserBean().getAvatar()); bundle.putString(Constants.USER_ICON, CommonAppConfig.getInstance().getUserBean().getAvatar());
fragment.setArguments(bundle); fragment.setArguments(bundle);
fragment.show(getSupportFragmentManager(), "LiveGuardBuyDialogFragment"); fragment.show(getSupportFragmentManager(), "LiveGuardBuyDialogFragment");
} }
/** /**
* 打开购买守护的弹窗 * 打开购买守护的弹窗
*/ */

View File

@ -34,6 +34,7 @@ import com.yunbao.live.bean.GuardUserBean;
import com.yunbao.live.bean.LiveGuardInfo; import com.yunbao.live.bean.LiveGuardInfo;
import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.http.LiveHttpUtil;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -52,6 +53,7 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements
private LiveGuardInfo mLiveGuardInfo; private LiveGuardInfo mLiveGuardInfo;
private String mLiveUid; private String mLiveUid;
private boolean mIsAnchor;//是否是主播 private boolean mIsAnchor;//是否是主播
private List<GuardUserBean> list=new ArrayList<>();
@Override @Override
protected int getLayoutId() { protected int getLayoutId() {
@ -112,6 +114,9 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements
private void initView() { private void initView() {
mRefreshView.setEmptyLayoutId(mIsAnchor ? R.layout.view_no_data_guard_anc : R.layout.view_no_data_guard_aud); 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)); mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
mGuardAdapter = new GuardAdapter(mContext, true, false);
mGuardAdapter.setList(list);
setAdapterData();
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<GuardUserBean>() { mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<GuardUserBean>() {
@Override @Override
public RefreshAdapter<GuardUserBean> getAdapter() { public RefreshAdapter<GuardUserBean> getAdapter() {
@ -129,36 +134,9 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements
@Override @Override
public List<GuardUserBean> processData(String[] info) { public List<GuardUserBean> processData(String[] info) {
List<GuardUserBean> list = JSON.parseArray(Arrays.toString(info), GuardUserBean.class); List<GuardUserBean> list = JSON.parseArray(Arrays.toString(info), GuardUserBean.class);
if (list.isEmpty()) { if(!list.isEmpty()){
userLayout.setVisibility(View.INVISIBLE); LiveNewGuardListDialogFragment.this.list=list;
}else { setAdapterData();
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);
}
} }
return list; return list;
} }
@ -183,7 +161,8 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements
} }
}); });
mRefreshView.initData(); mRefreshView.setRecyclerViewAdapter(mGuardAdapter);
mGuardAdapter.notifyDataSetChanged();
} }
@Override @Override
@ -198,4 +177,40 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements
initView(); initView();
return show; 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<GuardUserBean> list) {
this.list=list;
}
} }

View File

@ -245,8 +245,8 @@
android:id="@+id/guard_imageView" android:id="@+id/guard_imageView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="58dp" android:layout_height="58dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp" android:layout_marginTop="30dp"
android:layout_marginStart="125dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/guardian_img_wings" android:src="@drawable/guardian_img_wings"
android:visibility="invisible" android:visibility="invisible"
@ -257,7 +257,7 @@
android:layout_width="65dp" android:layout_width="65dp"
android:layout_height="65dp" android:layout_height="65dp"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginStart="-5dp" android:layout_marginStart="-6dp"
android:layout_marginTop="25dp" android:layout_marginTop="25dp"
android:layout_toEndOf="@+id/guard_imageView" android:layout_toEndOf="@+id/guard_imageView"
android:scaleType="centerCrop" android:scaleType="centerCrop"
@ -269,9 +269,9 @@
android:id="@+id/guard_imageView_one" android:id="@+id/guard_imageView_one"
android:layout_width="65dp" android:layout_width="65dp"
android:layout_height="65dp" android:layout_height="65dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp" android:layout_marginTop="25dp"
android:layout_toStartOf="@id/guard_imageView"
android:layout_toStartOf="@id/guard_imageView_two"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/guardian_img_wings" android:src="@drawable/guardian_img_wings"
android:visibility="invisible" android:visibility="invisible"

View File

@ -195,8 +195,8 @@
<com.makeramen.roundedimageview.RoundedImageView <com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/user_guard" android:id="@+id/user_guard"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@mipmap/img_guardian_empty" android:src="@mipmap/img_guardian_empty"