diff --git a/app/build.gradle b/app/build.gradle index 1b85e907f..8fcb7083c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -230,6 +230,7 @@ dependencies { annotationProcessor rootProject.ext.dependencies["arouter-compiler"] // implementation rootProject.ext.dependencies["leakcanary"] + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10' } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6d30238ee..1f229165b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,5 @@ PDLIVE + assertk.Assert \ No newline at end of file diff --git a/config.gradle b/config.gradle index 5038d9923..0993db55d 100644 --- a/config.gradle +++ b/config.gradle @@ -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", diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index e10ace99f..289f779b0 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -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; } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveMoreDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveMoreDialogFragment.java index ff6df9c59..10fa1a78e 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveMoreDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveMoreDialogFragment.java @@ -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(); } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java index 9f3278241..0f0a2867d 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java @@ -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; } } - });*/ + }); } diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index e6e9df4d2..9f4fdec6a 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -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; diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java index efec10260..440fcdce3 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java @@ -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(); diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java index 4756f499f..753250175 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java @@ -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(); diff --git a/live/src/main/java/com/yunbao/live/socket/SocketClient.java b/live/src/main/java/com/yunbao/live/socket/SocketClient.java index 7342b8199..1e313692c 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketClient.java @@ -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://全服通知 diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index 303242be8..f1b4f4e0c 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -220,9 +220,9 @@ public class SocketRyClient { int num = LiveAudienceActivity.fansNum + 1; LiveRoomViewHolder.setFansNum(num); } - if (map.getString("ct").contains("堅決維護青少年群體精神文明健康")||map.getString("ct").contains("click to register if you like. pdlive conducts")){ + if (map.getString("ct").contains("堅決維護青少年群體精神文明健康") || map.getString("ct").contains("click to register if you like. pdlive conducts")) { systemChatMessage(map.getString("ct")); - }else { + } else { systemChatMessage2(map.getString("ct")); } @@ -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) + ); } } 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 fa1b021fb..7962eb64f 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -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) {