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