直播间退出闪退问题

This commit is contained in:
18401019693 2022-09-07 19:52:48 +08:00
parent 2cbdac4bd0
commit f18e847baf
4 changed files with 27 additions and 29 deletions

View File

@ -4,8 +4,8 @@ ext {
buildToolsVersion: "28.0.3", buildToolsVersion: "28.0.3",
minSdkVersion : 21, minSdkVersion : 21,
targetSdkVersion : 30, targetSdkVersion : 30,
versionCode : 206, versionCode : 212,
versionName : "6.3.9" versionName : "6.4.1"
] ]
manifestPlaceholders = [ manifestPlaceholders = [
// //

View File

@ -120,7 +120,6 @@ public class LiveAudienceActivity extends LiveActivity {
//直播间进入房间队列 //直播间进入房间队列
private Handler liveHandler = new Handler(); private Handler liveHandler = new Handler();
@Override @Override
public <T extends View> T findViewById(@IdRes int id) { public <T extends View> T findViewById(@IdRes int id) {
@ -241,7 +240,7 @@ public class LiveAudienceActivity extends LiveActivity {
View rootView = viewGroup.findViewById(R.id.drawer_layout); View rootView = viewGroup.findViewById(R.id.drawer_layout);
if (rootView != null && rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) { if (rootView != null && rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) {
((ViewGroup) (rootView.getParent())).removeView(rootView); ((ViewGroup) (rootView.getParent())).removeView(rootView);
manager.onRemove(); manager.onRemove(false);
} }
} }
// 满足此种条件表明需要加载直播视频以及聊天室了 // 满足此种条件表明需要加载直播视频以及聊天室了
@ -306,7 +305,7 @@ public class LiveAudienceActivity extends LiveActivity {
View rootView = manager.getRootView(); View rootView = manager.getRootView();
if (rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) { if (rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) {
((ViewGroup) (rootView.getParent())).removeView(rootView); ((ViewGroup) (rootView.getParent())).removeView(rootView);
manager.onRemove(); manager.onRemove(false);
} }
mViewGroup.addView(manager.getRootView()); mViewGroup.addView(manager.getRootView());
@ -448,9 +447,7 @@ public class LiveAudienceActivity extends LiveActivity {
} else if (Micing == 2) { } else if (Micing == 2) {
manager.micIngTypeTwo(mLiveBean, mLiveType, mLiveTypeVal); manager.micIngTypeTwo(mLiveBean, mLiveType, mLiveTypeVal);
} else { } else {
manager.onRemove(); manager.onRemove(true);
super.onBackPressed();
} }
} catch (Exception e) { } catch (Exception e) {
@ -460,7 +457,8 @@ public class LiveAudienceActivity extends LiveActivity {
} }
public void end() { public void end() {
manager.end(); if (manager != null)
manager.end();
} }
/** /**
@ -583,7 +581,7 @@ public class LiveAudienceActivity extends LiveActivity {
LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE); LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE);
LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM); LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM);
LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE); LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE);
manager.onRemove(); manager.onRemove(false);
mLiveType = e.getLiveType(); mLiveType = e.getLiveType();
mLiveTypeVal = e.getLiveTypeVal(); mLiveTypeVal = e.getLiveTypeVal();
mLiveBean = liveBean; mLiveBean = liveBean;

View File

@ -17,7 +17,7 @@ public interface LivePlayListener extends LiveActivityLifeCallback {
/** /**
* 用户滑动移除该页面 * 用户滑动移除该页面
*/ */
void onRemove(); void onRemove(boolean isQuit);
/** /**
* @return 页面的根布局 View * @return 页面的根布局 View

View File

@ -1,10 +1,5 @@
package com.yunbao.live.views; package com.yunbao.live.views;
import static com.yunbao.common.CommonAppContext.logger;
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
import static com.yunbao.live.views.LivePlayRyViewHolder.Micing;
import static com.yunbao.live.views.LiveRoomViewHolder.isStayRoomfive;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
@ -102,6 +97,11 @@ import io.rong.imlib.chatroom.base.RongChatRoomClient;
import io.rong.imlib.model.Conversation; import io.rong.imlib.model.Conversation;
import io.rong.message.TextMessage; import io.rong.message.TextMessage;
import static com.yunbao.common.CommonAppContext.logger;
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
import static com.yunbao.live.views.LivePlayRyViewHolder.Micing;
import static com.yunbao.live.views.LiveRoomViewHolder.isStayRoomfive;
/** /**
* 竖屏直播间UI逻辑 * 竖屏直播间UI逻辑
*/ */
@ -286,13 +286,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
} }
@Override @Override
public void onRemove() { public void onRemove(boolean isQuit) {
LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE);
LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM);
LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE);
CommonHttpUtil.cancel(CommonHttpConsts.GET_BALANCE);
CommonHttpUtil.cancel(LiveHttpConsts.GET_WISH_LIST);
IMLoginManager.get(mContext).setisNewUserOne(false); IMLoginManager.get(mContext).setisNewUserOne(false);
//子线程执行退出操作 //子线程执行退出操作
exitLiveRoom(); exitLiveRoom();
if (mLiveAudienceViewHolder != null) { if (mLiveAudienceViewHolder != null) {
mLiveAudienceViewHolder.removeFromParent(); mLiveAudienceViewHolder.removeFromParent();
mLiveAudienceViewHolder.removeCallbacks(); mLiveAudienceViewHolder.removeCallbacks();
@ -312,18 +314,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLivePlayViewHolder.release(); mLivePlayViewHolder.release();
} }
mLivePlayViewHolder = null; mLivePlayViewHolder = null;
LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE);
LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM);
LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE);
CommonHttpUtil.cancel(CommonHttpConsts.GET_BALANCE);
CommonHttpUtil.cancel(LiveHttpConsts.GET_WISH_LIST);
if (mSocketClient != null) { if (mSocketClient != null) {
mSocketClient.disConnect(); mSocketClient.disConnect();
mSocketClient = null; mSocketClient = null;
} }
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.removeFromParent(); mLiveRoomViewHolder.removeFromParent();
mLiveRoomViewHolder.clearData(); mLiveRoomViewHolder.clearData();
@ -348,7 +344,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRyLinkMicPkPresenter.clearData(); mLiveRyLinkMicPkPresenter.clearData();
mLiveRyLinkMicPkPresenter.release(); mLiveRyLinkMicPkPresenter.release();
} }
if (isQuit) {
if (mContext instanceof LiveAudienceActivity) {
mContext.finish();
}
}
} }
@Override @Override
@ -1369,7 +1369,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
* 退出直播间 * 退出直播间
*/ */
public void exitLiveRoom() { public void exitLiveRoom() {
if(mLiveBean==null) { if (mLiveBean == null) {
return; return;
} }
RongChatRoomClient.getInstance().quitChatRoom("g" + mLiveBean.getUid(), new IRongCoreCallback.OperationCallback() { RongChatRoomClient.getInstance().quitChatRoom("g" + mLiveBean.getUid(), new IRongCoreCallback.OperationCallback() {