From d1edf6bdd8e2e6961760aa81caa9540998c98d6f Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 11 Sep 2023 10:41:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=BB=E6=92=AD=E5=85=B3?= =?UTF-8?q?=E6=92=AD=E6=97=B6=EF=BC=8C=E7=94=A8=E6=88=B7=E7=AB=AF=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E7=A6=BB=E5=BC=80=E6=88=BF=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/views/LiveEndViewHolder.java | 70 ++++++++++++++++++- .../live/views/LivePlayRyViewHolder.java | 4 +- .../live/views/PortraitLiveManager.java | 6 +- 3 files changed, 75 insertions(+), 5 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java index 50dca2573..4700fed5f 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java @@ -47,6 +47,10 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import io.rong.imlib.IRongCoreCallback; +import io.rong.imlib.IRongCoreEnum; +import io.rong.imlib.chatroom.base.RongChatRoomClient; + /** * Created by cxf on 2018/10/9. */ @@ -66,10 +70,13 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList private RecyclerView likeList; private SearchRecommendBodyAdapter adapter; private IMLoginModel model = null; + private String live_id; + private String leaveStream, leaveGroupId; public LiveEndViewHolder(Context context, ViewGroup parentView, String uid) { super(context, parentView); model = IMLoginManager.get(mContext).getUserInfo(); + this.live_id = uid; if (TextUtils.equals(model.getId() + "", uid)) { type = LiveOfType.ANCHOR; } else { @@ -77,6 +84,14 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList } } + public void setLeaveStream(String leaveStream) { + this.leaveStream = leaveStream; + } + + public void setLeaveGroupId(String leaveGroupId) { + this.leaveGroupId = leaveGroupId; + } + @Override protected int getLayoutId() { return R.layout.view_live_end; @@ -91,6 +106,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList if (type == LiveOfType.USER) { initViewOfUser(); initDataOfUser(); + endLive(); anchorLiveEnd.setVisibility(View.GONE); } else { userLiveEnd.setVisibility(View.GONE); @@ -99,6 +115,58 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList } + private void endLive() { + + + RongChatRoomClient.getInstance().quitChatRoom("g" + live_id, new IRongCoreCallback.OperationCallback() { + @Override + public void onSuccess() { + try { + Log.i("tx", "退出成功" + live_id); + LiveNetManager.get(mContext) + .leaveRoomNew(leaveStream, leaveGroupId, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(String data) { + + } + + @Override + public void onError(String error) { + } + }); + leaveStream = ""; + leaveGroupId = ""; + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + @Override + public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) { + try { + + Log.i("tx", "退出成功" + live_id); + LiveNetManager.get(mContext) + .leaveRoomNew(leaveStream, leaveGroupId, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(String data) { + } + + @Override + public void onError(String error) { + } + }); + leaveStream = ""; + leaveGroupId = ""; + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + /** * 加载用户猜你喜欢数据 */ @@ -132,7 +200,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList @Override public void onError(String error) { - ToastUtil.show( R.string.net_error); + ToastUtil.show(R.string.net_error); } }); } diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 9b9a91db4..d450c23af 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -1271,11 +1271,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { Player.Listener.super.onPlaybackStateChanged(playbackState); if (playbackState == Player.STATE_BUFFERING) { //showLoadingDialog(); - //mLoading.setVisibility(View.VISIBLE); + mLoading.setVisibility(View.VISIBLE); OkDownload.getInstance().pauseAll(); Log.i(TAG, "onPlaybackStateChanged: 缓存中"); } else { - //mLoading.setVisibility(View.INVISIBLE); + mLoading.setVisibility(View.INVISIBLE); Log.i(TAG, "onPlaybackStateChanged: 播放中"); } } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 9e0461569..0df33d47d 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -449,7 +449,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.setUserList(data.getEnterRoomInfo().getUserlists()); //设置靓号 mLiveRoomViewHolder.setAnchorGoodNumber(data.getLiveInfo().getGoodnum()); - if(!StringUtil.isEmpty(mLiveBean.getGiftId())){ + if (!StringUtil.isEmpty(mLiveBean.getGiftId())) { mLiveRoomViewHolder.openGiftDialog(mLiveBean.getGiftId()); } List bannerBeans = new ArrayList<>(); @@ -680,7 +680,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.showPrizePoolLevel(String.valueOf(giftPrizePoolLevel)); } } - AppManager.runDebugCode(()->{ + AppManager.runDebugCode(() -> { liveHandler.postDelayed(loadTimeoutRunnableGone, 1_000); }); liveHandler.postDelayed(loadTimeoutRunnableGone, 15_000); @@ -1285,6 +1285,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } if (mLiveEndViewHolder == null) { mLiveEndViewHolder = new LiveEndViewHolder(mContext, mSecondPage, mLiveBean.getUid()); + mLiveEndViewHolder.setLeaveGroupId(leaveGroupId); + mLiveEndViewHolder.setLeaveStream(leaveStream); mLiveEndViewHolder.subscribeActivityLifeCycle(); mLiveEndViewHolder.addToParent(); Bus.get().post(new LiveGiftDialogEvent());