优化观众直播间PortraitLiveManager的强引用导致的内存泄漏
This commit is contained in:
parent
17d18eff98
commit
3e7942dbd4
@ -230,6 +230,7 @@ dependencies {
|
||||
annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
|
||||
|
||||
// implementation rootProject.ext.dependencies["leakcanary"]
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">PDLIVE</string>
|
||||
<string name="leak_canary_test_class_name">assertk.Assert</string>
|
||||
</resources>
|
@ -10,9 +10,9 @@ ext {
|
||||
manifestPlaceholders = [
|
||||
//正式
|
||||
|
||||
serverHost : "https://napi.yaoulive.com",
|
||||
// serverHost : "https://napi.yaoulive.com",
|
||||
//測試
|
||||
// serverHost : "https://ceshi.yaoulive.com",
|
||||
serverHost : "https://ceshi.yaoulive.com",
|
||||
|
||||
//腾讯地图
|
||||
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",
|
||||
|
@ -140,7 +140,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
private LiveBean mLiveBean;
|
||||
//当前直播间下标
|
||||
private int mCurrentItem, mCurrentPage;
|
||||
private static PortraitLiveManager manager;
|
||||
private PortraitLiveManager manager;
|
||||
private int mLastPosition = -1;
|
||||
|
||||
private ViewGroup mViewGroup;
|
||||
@ -217,12 +217,12 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
manager.setBackIndex(backIndex);
|
||||
}
|
||||
|
||||
public static LiveRoomPlayViewHolder getmLivePlayViewHolder() {
|
||||
public LiveRoomPlayViewHolder getmLivePlayViewHolder() {
|
||||
|
||||
return manager == null ? null : manager.getmLivePlayViewHolder();
|
||||
}
|
||||
|
||||
public static void setCurrentItem(int index) {
|
||||
public void setCurrentItem(int index) {
|
||||
manager.mViewPager.setCurrentItem(index);
|
||||
}
|
||||
|
||||
@ -1219,6 +1219,18 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
manager.mLiveRoomViewHolder.updataCleanMic();
|
||||
}
|
||||
break;
|
||||
case SOCKET_LIVE_DRPK_SET_PK_VIEW:
|
||||
ToastUtil.show("setPkView");
|
||||
if (manager.getmLivePlayViewHolder() != null) {
|
||||
manager.getmLivePlayViewHolder().setPkview();
|
||||
}
|
||||
break;
|
||||
case SOCKET_LIVE_DRPK_SET_PK_END_VIEW:
|
||||
ToastUtil.show("setPkEndview");
|
||||
if (manager.getmLivePlayViewHolder() != null) {
|
||||
manager.getmLivePlayViewHolder().setPkEndview();
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,8 @@ public class LiveMoreDialogFragment extends AbsDialogFragment {
|
||||
dismiss();
|
||||
if (((LiveAudienceActivity) mContext).pkInfo != null && ((LiveAudienceActivity) mContext).pkInfo.getIntValue("ifpk") == 0 && ((LiveAudienceActivity) mContext).anyway.equals("1") && LiveRoomViewHolder.d_pk_view.getVisibility() != View.VISIBLE) {
|
||||
((LiveAudienceActivity) mContext).btnSmallScreen.setVisibility(View.VISIBLE);
|
||||
LiveAudienceActivity.setCurrentItem(0);
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().fullScreen();
|
||||
((LiveAudienceActivity) mContext).setCurrentItem(0);
|
||||
((LiveAudienceActivity) mContext).getmLivePlayViewHolder().fullScreen();
|
||||
} else {
|
||||
Toast.makeText(mContext, "当前模式不能全屏", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
mHonorLayout.setOnClickListener(v -> forwardHomePage());
|
||||
|
||||
//用户名片连点三次粉丝弹出视频debug窗
|
||||
/* mFansVal.setOnClickListener(new View.OnClickListener() {
|
||||
mFansVal.setOnClickListener(new View.OnClickListener() {
|
||||
long time=0;
|
||||
int index=0;
|
||||
@Override
|
||||
@ -271,7 +271,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
time=0;
|
||||
}
|
||||
}
|
||||
});*/
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -194,6 +194,8 @@ public class LiveAudienceEvent extends BaseModel {
|
||||
LINK_MIC_UPDATE_MIC_LIST(41, "更新连麦列表"),
|
||||
LINK_MIC_UPDATE_AUDIENCE_LIST(42, "更新观众/可邀请列表"),
|
||||
LINK_MIC_CLOSE(43, "主播关闭连麦房"),
|
||||
SOCKET_LIVE_DRPK_SET_PK_VIEW(44, "setPkview"),
|
||||
SOCKET_LIVE_DRPK_SET_PK_END_VIEW(45, "setPkEndview"),
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
@ -1002,8 +1002,8 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
|
||||
mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
|
||||
mLiveLinkMicPkViewHolder.addToParent();
|
||||
mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor);
|
||||
if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
if (mContext instanceof LiveAudienceActivity) {
|
||||
((LiveAudienceActivity) mContext).getmLivePlayViewHolder().setPkview();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1081,8 +1081,8 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
if ( LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
|
||||
if (mContext instanceof LiveAudienceActivity) {
|
||||
((LiveAudienceActivity) mContext).getmLivePlayViewHolder().setPkEndview();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -1838,8 +1838,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
|
||||
mLiveLinkMicPkViewHolder.addToParent();
|
||||
mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor);
|
||||
if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
if (mContext instanceof LiveAudienceActivity) {
|
||||
((LiveAudienceActivity) mContext).getmLivePlayViewHolder().setPkview();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1957,8 +1957,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
public void run() {
|
||||
// try {
|
||||
// Thread.sleep(4000);
|
||||
if (mContext instanceof LiveAudienceActivity && LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
|
||||
if (mContext instanceof LiveAudienceActivity) {
|
||||
((LiveAudienceActivity) mContext).getmLivePlayViewHolder().setPkEndview();
|
||||
}
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
|
@ -19,6 +19,7 @@ import com.yunbao.common.bean.FansMedalBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
@ -33,6 +34,7 @@ import com.yunbao.live.bean.LiveLuckGiftWinBean;
|
||||
import com.yunbao.live.bean.LivePKUserListBean;
|
||||
import com.yunbao.live.bean.LiveReceiveGiftBean;
|
||||
import com.yunbao.common.bean.LiveUserGiftBean;
|
||||
import com.yunbao.live.event.LiveAudienceEvent;
|
||||
import com.yunbao.live.presenter.LiveLinkMicPkPresenter;
|
||||
import com.yunbao.live.views.LivePlayKsyViewHolder;
|
||||
import com.yunbao.live.views.LivePushTxViewHolder;
|
||||
@ -171,7 +173,10 @@ public class SocketClient {
|
||||
LiveRoomViewHolder.d_pk_view.setVisibility(View.GONE);
|
||||
//創建了多人房間
|
||||
} else if (action3 == 9) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
// LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case Constants.SOCKET_ALL_SERVER_NOTIFY://全服通知
|
||||
|
@ -288,7 +288,10 @@ public class SocketRyClient {
|
||||
}
|
||||
LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, map.getIntValue("drpk_time"));
|
||||
if (livePushRyViewHolder == null) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
// LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
|
||||
);
|
||||
}
|
||||
|
||||
} else if (action3 == 5) {
|
||||
@ -302,17 +305,27 @@ public class SocketRyClient {
|
||||
leaveDRRoom();
|
||||
isDRPK = 0;
|
||||
} else {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
|
||||
// LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW)
|
||||
);
|
||||
|
||||
}
|
||||
//創建了多人房間
|
||||
} else if (action3 == 3) {
|
||||
if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
||||
/* if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
}
|
||||
}*/
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
|
||||
);
|
||||
isDRPK = 1;
|
||||
} else if (action3 == 10) {
|
||||
if (!map.getString("uid").equals(CommonAppConfig.getInstance().getUid())) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
// LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ import com.tencent.live2.V2TXLivePlayer;
|
||||
import com.tencent.live2.V2TXLivePlayerObserver;
|
||||
import com.tencent.live2.impl.V2TXLivePlayerImpl;
|
||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
@ -356,9 +357,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
"音频码率:" + statistics.audioBitrate + "\n" +
|
||||
"FPS:" + statistics.fps + "\n" +
|
||||
"CPU:" + statistics.appCpu + "\n" +
|
||||
"剩余内存:" + DeviceUtils.getMemory(mContext) + "\n" +
|
||||
"分辨率:" + statistics.height + "x" + statistics.width + "\n" +
|
||||
"播放状态:" + mPlayer.isPlaying() + "\n" +
|
||||
"当前时间:" + new SimpleDateFormat("HH:mm:ss", Locale.CHINA).format(new Date()) + "\n";
|
||||
"运行时间:" + (System.currentTimeMillis()- Constants.runTime)/1000 + "\n";
|
||||
debugView.setText(debugText);
|
||||
Log.i(TAG, "onStatisticsUpdate: " + JSON.toJSONString(statistics) + " |当前下载数 : " + OkDownload.getInstance().getTaskMap().size() + buffer);
|
||||
if (statistics.height > statistics.width) {
|
||||
|
Loading…
Reference in New Issue
Block a user