From 5bec6c1b7970bdcb9e35a0eba37850ba86070b1e Mon Sep 17 00:00:00 2001 From: ningwenqiang Date: Fri, 23 Aug 2024 16:19:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=86=E5=A4=87=E6=8F=90=E4=BA=A4=E6=9A=82?= =?UTF-8?q?=E5=81=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceunity/agora/SWAuManager.java | 5 ++++ .../live/activity/LiveAudienceActivity.java | 16 ++++++++++++- .../live/views/LivePlaySwViewHolder.java | 24 ++++++++++++++----- .../yunbao/live/views/LiveRoomViewHolder.java | 3 +++ .../live/views/PortraitLiveManager.java | 7 +++++- 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java index e8ba2b415..b19fac339 100644 --- a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java +++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java @@ -171,6 +171,8 @@ public class SWAuManager extends BaseCacheManager { frameLayout.addView(surfaceView); VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid); + + Log.i("nwq","updateMyChannelView::setupRemoteVideo"); mRtcEngine.setupRemoteVideo(videoCanvas); } @@ -232,6 +234,7 @@ public class SWAuManager extends BaseCacheManager { // surfaceView.setZOrderMediaOverlay(true); pkContainer1.addView(surfaceView); VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, strUid); + Log.i("nwq","joinExRoomEx::setupRemoteVideoEx"); mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); } }); @@ -312,6 +315,7 @@ public class SWAuManager extends BaseCacheManager { // surfaceView.setZOrderMediaOverlay(true); frameLayout.addView(surfaceView); VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, Integer.parseInt(toUid)); + Log.i("nwq","joinChannelDrEx::setupRemoteVideoEx"); mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); } }); @@ -393,6 +397,7 @@ public class SWAuManager extends BaseCacheManager { // surfaceView.setZOrderMediaOverlay(true); audienceContainer.addView(surfaceView); // 将 TextureView 对象传入声网实时互动 SDK,设置远端视图 + Log.i("nwq","setupRemoteVideo::setupRemoteVideo"); mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid)); } 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 e68d9ffa6..e41b6c111 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -638,8 +638,13 @@ public class LiveAudienceActivity extends LiveActivity { } + @Override public void onBackPressed() { + if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + return; + } if (manager != null && manager.getsudGameMin()) { new XPopup.Builder(mContext).asCustom(new HintCustomPopup(mContext, mContext.getString(com.yunbao.common.R.string.dialog_tip), mContext.getString(com.yunbao.common.R.string.the_live_room)).setLiveOpenOk(mContext.getString(com.yunbao.common.R.string.confirm)).setLiveOpenCancel(mContext.getString(com.yunbao.common.R.string.cancel)).setCallBack(new HintCustomPopup.HintCustomCallBack() { @Override @@ -914,9 +919,18 @@ public class LiveAudienceActivity extends LiveActivity { onConfigurationChangedView(newConfig); } - public void onConfigurationChangedView( Configuration newConfig) { + public void onConfigurationChangedView(Configuration newConfig) { + // liveHandler.post(liveRunnable); if (manager != null && manager.getRootView() != null && mLiveBean != null && mViewGroup != null) { + Log.i("nwq", "横竖屏进行切换"); manager.onConfigurationChanged(newConfig); + // liveHandler.post(liveRunnable); +// View rootView = manager.getRootView(); +// if (rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) { +// ((ViewGroup) (rootView.getParent())).removeView(rootView); +// manager.onRemove(false); +// } +// mViewGroup.addView(manager.getRootView()); manager.onAdd(mLiveBean, mLiveType, mLiveTypeVal, mLiveSDK, isSw); } diff --git a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java index 5c3a51c54..b333f9bb1 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java @@ -192,10 +192,6 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { if (contexts == null) { return; } - //如果mContentView有父类则移除 - if (mContentView != null && mContentView.getParent() != null) { - ((ViewGroup) mContentView.getParent()).removeView(mContentView); - } //这里考虑只通过修改参数的方式实现 if (isPhysicalScreenVertical()) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams(); @@ -214,6 +210,15 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { dr_pk_view.requestLayout(); } + params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); + params.height = DpUtil.dp2px(280); + params.topMargin = DpUtil.dp2px(130); + ry_view.setLayoutParams(params); + if (ry_view.getVisibility() == View.VISIBLE) { + ry_view.requestLayout(); + } + + } else { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams(); params.height = ViewGroup.LayoutParams.MATCH_PARENT; @@ -230,9 +235,16 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { if (dr_pk_view.getVisibility() == View.VISIBLE) { dr_pk_view.requestLayout(); } + + params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + params.topMargin = 0; + ry_view.setLayoutParams(params); + if (ry_view.getVisibility() == View.VISIBLE) { + ry_view.requestLayout(); + } } - - + swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, liveUid, SWAuManager.getChannelName(liveUid)); } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index f9162d9b8..d242b2b9f 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -2369,6 +2369,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void resetViewGone() { goto_room_view.setVisibility(View.GONE); mPkRankTopIcon.setVisibility(View.GONE); + Log.i("nwq","LiveRoomViewHolder::resetViewGone"); lt_pk_line.setVisibility(View.GONE); time.setVisibility(View.GONE); if (!SpUtil.getInstance().getBooleanValue("private_chat_message_switch")) { @@ -3306,7 +3307,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis //双人pk显示 public void UpPkTwo() { + Log.i("nwq","LiveRoomViewHolder::UpPkTwo"); if (lt_pk_line.getVisibility() == View.VISIBLE) return; + Log.i("nwq","LiveRoomViewHolder::UpPkTwo22"); ScreenDimenUtil util = ScreenDimenUtil.getInstance(); int mScreenWdith = util.getScreenWdith(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams(); 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 68694ce70..146b0771f 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -1130,7 +1130,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onConfigurationChanged(Configuration newConfig) { - mLivePlayViewHolder.onConfigureChange(); + mLiveRoomViewHolder.removeView(); + mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager(), isSw); + mLiveRoomViewHolder.subscribeActivityLifeCycle(); + mLiveRoomViewHolder.addToParent(); + + // mLivePlayViewHolder.onConfigureChange(); } @Override