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;
@ -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) {
@ -1261,11 +1262,20 @@ 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() {
LiveHttpUtil.getGuardList(mLiveUid, 1, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
List<GuardUserBean> list = JSON.parseArray(Arrays.toString(info), GuardUserBean.class);
if(list.isEmpty()){
openNewBuyGuardWindow();
}else {
LiveNewGuardListDialogFragment fragment = new LiveNewGuardListDialogFragment(); LiveNewGuardListDialogFragment fragment = new LiveNewGuardListDialogFragment();
fragment.setList(list);
fragment.setLiveGuardInfo(mLiveGuardInfo); fragment.setLiveGuardInfo(mLiveGuardInfo);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(Constants.LIVE_UID, mLiveUid); bundle.putString(Constants.LIVE_UID, mLiveUid);
@ -1273,6 +1283,10 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
fragment.setArguments(bundle); fragment.setArguments(bundle);
fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment"); fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment");
} }
}
});
}
/** /**
* 打開粉絲團 * 打開粉絲團
@ -1342,6 +1356,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
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,6 +134,50 @@ 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()){
LiveNewGuardListDialogFragment.this.list=list;
setAdapterData();
}
return list;
}
@Override
public void onRefreshSuccess(List<GuardUserBean> list, int listCount) {
}
@Override
public void onRefreshFailure() {
}
@Override
public void onLoadMoreSuccess(List<GuardUserBean> loadItemList, int loadItemCount) {
}
@Override
public void onLoadMoreFailure() {
}
});
mRefreshView.setRecyclerViewAdapter(mGuardAdapter);
mGuardAdapter.notifyDataSetChanged();
}
@Override
public void onClick(View view) {
dismiss();
((LiveActivity) mContext).openNewBuyGuardWindow();
}
@Override
public int show(@NonNull FragmentTransaction transaction, @Nullable String tag) {
int show = super.show(transaction, tag);
initView();
return show;
}
private void setAdapterData(){
if (list.isEmpty()) { if (list.isEmpty()) {
userLayout.setVisibility(View.INVISIBLE); userLayout.setVisibility(View.INVISIBLE);
}else { }else {
@ -160,42 +209,8 @@ public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements
mBtnBuy.setText(R.string.guard_buy_3); mBtnBuy.setText(R.string.guard_buy_3);
} }
} }
return list;
} }
public void setList(List<GuardUserBean> list) {
@Override this.list=list;
public void onRefreshSuccess(List<GuardUserBean> list, int listCount) {
}
@Override
public void onRefreshFailure() {
}
@Override
public void onLoadMoreSuccess(List<GuardUserBean> loadItemList, int loadItemCount) {
}
@Override
public void onLoadMoreFailure() {
}
});
mRefreshView.initData();
}
@Override
public void onClick(View view) {
dismiss();
((LiveActivity) mContext).openNewBuyGuardWindow();
}
@Override
public int show(@NonNull FragmentTransaction transaction, @Nullable String tag) {
int show = super.show(transaction, tag);
initView();
return show;
} }
} }

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"