调整多人连麦踢人后刷新列表

This commit is contained in:
zlzw 2022-11-23 14:42:00 +08:00
parent 3d117dbcb4
commit d42835231e
2 changed files with 19 additions and 9 deletions

View File

@ -20,6 +20,7 @@ import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.LevelBean; import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.API; import com.yunbao.common.http.API;
@ -52,6 +53,7 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
public static final int TYPE_MIC_INVITE = 3;//邀请连麦 public static final int TYPE_MIC_INVITE = 3;//邀请连麦
private AbsDialogFragment fragments; private AbsDialogFragment fragments;
private CommonRefreshView refreshView;
private String mLiveUid; private String mLiveUid;
public AnchorUserMicInfoAdapter(Context context, AbsDialogFragment fragment) { public AnchorUserMicInfoAdapter(Context context, AbsDialogFragment fragment) {
@ -62,10 +64,13 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
return position; return position;
} }
public void setRefreshView(CommonRefreshView refreshView) {
this.refreshView = refreshView;
}
public void setLiveUid(String mLiveUid) { public void setLiveUid(String mLiveUid) {
this.mLiveUid = mLiveUid; this.mLiveUid = mLiveUid;
} }
@ -111,11 +116,11 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
mBtn.setOnClickListener(v -> { mBtn.setOnClickListener(v -> {
if (v.getTag() != null) { if (v.getTag() != null) {
MicUserBean tag = (MicUserBean) v.getTag(); MicUserBean tag = (MicUserBean) v.getTag();
if(tag.getType()==TYPE_MIC_REQUEST) { if (tag.getType() == TYPE_MIC_REQUEST) {
applyMic(tag, 4,createSocketSendBean()); applyMic(tag, 4, createSocketSendBean());
}else if(tag.getType()==TYPE_MIC_INVITE){ } else if (tag.getType() == TYPE_MIC_INVITE) {
SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId()); SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId());
applyMic(tag, 1,bean); applyMic(tag, 1, bean);
} }
} }
}); });
@ -128,21 +133,23 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
.subscribe(new Consumer<ResponseModel<BaseModel>>() { .subscribe(new Consumer<ResponseModel<BaseModel>>() {
@Override @Override
public void accept(ResponseModel<BaseModel> stringResponseModel) throws Exception { public void accept(ResponseModel<BaseModel> stringResponseModel) throws Exception {
applyMic((MicUserBean) v.getTag(), 8,createSocketSendBean()); applyMic((MicUserBean) v.getTag(), 8, createSocketSendBean());
} }
}, Throwable::printStackTrace).isDisposed(); }, Throwable::printStackTrace).isDisposed();
} }
}); });
} }
SocketSendBean createSocketSendBean(){
return new SocketSendBean() SocketSendBean createSocketSendBean() {
return new SocketSendBean()
.param("_method_", Constants.LIAN_MAI) .param("_method_", Constants.LIAN_MAI)
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("avatar", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("avatar", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("uid", CommonAppConfig.getInstance().getUid()); .param("uid", CommonAppConfig.getInstance().getUid());
} }
void applyMic(MicUserBean bean, int action,SocketSendBean msg) {
void applyMic(MicUserBean bean, int action, SocketSendBean msg) {
msg.param("action", action); msg.param("action", action);
msg.create(); msg.create();
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
@ -157,12 +164,14 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
@Override @Override
public void onSuccess(io.rong.imlib.model.Message message) { public void onSuccess(io.rong.imlib.model.Message message) {
Log.e("ry", "发送成功"); Log.e("ry", "发送成功");
refreshView.initData();
} }
@Override @Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("ry", "发送失敗" + errorCode.toString()); Log.e("ry", "发送失敗" + errorCode.toString());
refreshView.initData();
} }
}); });
} }

View File

@ -224,6 +224,7 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
}); });
userMicInfoAdapter = new AnchorUserMicInfoAdapter(mContext, LiveMicAnchorDialogFragment.this); userMicInfoAdapter = new AnchorUserMicInfoAdapter(mContext, LiveMicAnchorDialogFragment.this);
userMicInfoAdapter.setLiveUid(mLiveUid); userMicInfoAdapter.setLiveUid(mLiveUid);
userMicInfoAdapter.setRefreshView(mRefreshView);
Up(); Up();
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<MicUserBean>() { mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<MicUserBean>() {