From 1df8d443f7915f8167f980cde5e592d13713eb42 Mon Sep 17 00:00:00 2001 From: ningwenqiang Date: Thu, 22 Aug 2024 13:52:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=B5=81=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=A8=AA=E5=B1=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/views/AbsViewHolder.java | 5 + gradle.properties | 4 +- .../faceunity/agora/SWAuManager.java | 2 +- .../live/activity/LiveAudienceActivity.java | 21 +- .../live/views/LivePlaySwViewHolder.java | 206 +++++++++++++----- .../yunbao/live/views/LiveRoomViewHolder.java | 37 +++- .../live/views/PortraitLiveManager.java | 7 +- .../res/layout-land/view_live_play_sw.xml | 11 +- .../main/res/layout-land/view_live_room.xml | 1 + 9 files changed, 208 insertions(+), 86 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/views/AbsViewHolder.java b/common/src/main/java/com/yunbao/common/views/AbsViewHolder.java index b28a9f85a..9361493d7 100644 --- a/common/src/main/java/com/yunbao/common/views/AbsViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/AbsViewHolder.java @@ -43,6 +43,11 @@ public abstract class AbsViewHolder implements LifeCycleListener { } + public void onConfigureChange() { + //如果 mParentView + } + + protected abstract int getLayoutId(); public abstract void init(); diff --git a/gradle.properties b/gradle.properties index c41a7a913..d015f4ba1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,6 +24,6 @@ android.nonTransitiveRClass=false systemProp.http.proxyHost=127.0.0.1 systemProp.https.proxyHost=127.0.0.1 -systemProp.https.proxyPort=7890 -systemProp.http.proxyPort=7890 +systemProp.https.proxyPort=9098 +systemProp.http.proxyPort=9098 #android.enableR8.fullMode=true \ No newline at end of file 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 e4562b9dc..e8ba2b415 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 @@ -188,7 +188,7 @@ public class SWAuManager extends BaseCacheManager { // 创建一个 TextureView 对象,并将其作为 FrameLayout 的子对象 TextureView surfaceView = new TextureView(mContext); audienceContainer.addView(surfaceView); - + Log.i("nwq"," audienceContainer.getChildCount()"+ audienceContainer.getChildCount()); // 启用视频模块 mRtcEngine.enableVideo(); 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 998afeb15..e68d9ffa6 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -291,9 +291,6 @@ public class LiveAudienceActivity extends LiveActivity { }; - - - /** * 初始化界面 */ @@ -911,11 +908,21 @@ public class LiveAudienceActivity extends LiveActivity { @Override public void onConfigurationChanged(@NonNull Configuration newConfig) { super.onConfigurationChanged(newConfig); - Log.i(TAG,"onConfigurationChanged"); + Log.i(TAG, "onConfigurationChanged"); adjustFullScreen(newConfig); - liveHandler.post(liveRunnable); + + onConfigurationChangedView(newConfig); } + public void onConfigurationChangedView( Configuration newConfig) { + if (manager != null && manager.getRootView() != null && mLiveBean != null && mViewGroup != null) { + manager.onConfigurationChanged(newConfig); + manager.onAdd(mLiveBean, mLiveType, mLiveTypeVal, mLiveSDK, isSw); + } + + } + + private void adjustFullScreen(Configuration config) { final WindowInsetsControllerCompat insetsController = ViewCompat.getWindowInsetsController(getWindow().getDecorView()); if (insetsController == null) return; @@ -1897,9 +1904,9 @@ public class LiveAudienceActivity extends LiveActivity { if (manager == null || manager.mLiveAudienceViewHolder == null || manager.mLiveAudienceViewHolder.mRedPoint == null) { return; } - if(event.getNumber()>0){ + if (event.getNumber() > 0) { manager.mLiveAudienceViewHolder.mRedPoint.setVisibility(View.VISIBLE); - }else{ + } else { manager.mLiveAudienceViewHolder.mRedPoint.setVisibility(View.GONE); } 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 b45b86758..5c3a51c54 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java @@ -5,6 +5,7 @@ import android.Manifest; import android.app.Activity; import android.app.Dialog; import android.content.Context; +import android.content.res.Configuration; import android.graphics.Color; import android.media.AudioManager; import android.os.Build; @@ -135,6 +136,10 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { return landscape; } + private boolean isPhysicalScreenVertical() { + return contexts.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; + } + public LivePlaySwViewHolder(Context context, ViewGroup parentView, int landscapes) { super(context, parentView); contexts = context; @@ -183,6 +188,54 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { dr_pk_view.setVisibility(View.GONE); } + public void onConfigureChange() { + 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(); + params.height = DpUtil.dp2px(280); + params.topMargin = DpUtil.dp2px(130); + mPkContainer.setLayoutParams(params); + if (mPkContainer.getVisibility() == View.VISIBLE) { + mPkContainer.requestLayout(); + } + + params = (RelativeLayout.LayoutParams) dr_pk_view.getLayoutParams(); + params.height = DpUtil.dp2px(280); + params.topMargin = DpUtil.dp2px(130); + dr_pk_view.setLayoutParams(params); + if (dr_pk_view.getVisibility() == View.VISIBLE) { + dr_pk_view.requestLayout(); + } + + } else { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams(); + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + params.topMargin = 0; + mPkContainer.setLayoutParams(params); + if (mPkContainer.getVisibility() == View.VISIBLE) { + mPkContainer.requestLayout(); + } + + params = (RelativeLayout.LayoutParams) dr_pk_view.getLayoutParams(); + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + params.topMargin = 0; + dr_pk_view.setLayoutParams(params); + if (dr_pk_view.getVisibility() == View.VISIBLE) { + dr_pk_view.requestLayout(); + } + } + + + } + + public void initSwEngine(String liveUid) { dr_pk_view.setVisibility(View.GONE); this.liveUid = liveUid; @@ -224,7 +277,6 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { @Override public void onSuccess(io.rong.imlib.model.Message message) { Log.e("ry", "发送成功"); - IMCenter.getInstance().deleteRemoteMessages(Conversation.ConversationType.PRIVATE, message.getTargetId(), new Message[]{message}, null); IMCenter.getInstance().clearMessagesUnreadStatus(Conversation.ConversationType.PRIVATE, message.getTargetId(), null); MicedUserManager.get().removeMiscUser(CommonAppConfig.getInstance().getUid()); @@ -464,8 +516,49 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { Log.i(TAG, "setLiveBeanLandscape: " + landscape + " isPk: " + isPk); this.landscape = landscape; this.videoLandscape = landscape; - if (landscape == 2) { - Log.i(TAG, "还原9:16"); + if (isPhysicalScreenVertical()) { + if (landscape == 2) { + Log.i(TAG, "还原9:16"); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); + params.height = RelativeLayout.LayoutParams.MATCH_PARENT; + params.topMargin = 0; + ry_view.setLayoutParams(params); + ry_view.requestLayout(); + + /* RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); + params1.height = RelativeLayout.LayoutParams.MATCH_PARENT; + params1.topMargin = 0; + ry_view.setLayoutParams(params1); + ry_view.requestLayout();*/ + RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); + params2.height = RelativeLayout.LayoutParams.MATCH_PARENT; + params2.topMargin = 0; + mCover.setLayoutParams(params2); + mCover.requestLayout(); + + } else { + Log.i(TAG, "还原16:9"); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); + params.height = vHeight; + params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + params.addRule(RelativeLayout.ALIGN_TOP); + ry_view.setLayoutParams(params); + ry_view.requestLayout(); + + /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); + params1.height = vHeight; + params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + params1.addRule(RelativeLayout.ALIGN_TOP); + ry_view.setLayoutParams(params1); + ry_view.requestLayout();*/ + RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); + params2.height = DpUtil.dp2px(270); + params2.topMargin = DpUtil.dp2px(120); + mCover.setLayoutParams(params2); + mCover.requestLayout(); + } + } else { + Log.i(TAG, "还原横屏 16:9"); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.topMargin = 0; @@ -482,27 +575,6 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { params2.topMargin = 0; mCover.setLayoutParams(params2); mCover.requestLayout(); - - } else { - Log.i(TAG, "还原16:9"); - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); - params.height = vHeight; - params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); - params.addRule(RelativeLayout.ALIGN_TOP); - ry_view.setLayoutParams(params); - ry_view.requestLayout(); - - /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); - params1.height = vHeight; - params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); - params1.addRule(RelativeLayout.ALIGN_TOP); - ry_view.setLayoutParams(params1); - ry_view.requestLayout();*/ - RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); - params2.height = DpUtil.dp2px(270); - params2.topMargin = DpUtil.dp2px(120); - mCover.setLayoutParams(params2); - mCover.requestLayout(); } } @@ -618,7 +690,7 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params1.addRule(RelativeLayout.ALIGN_TOP); ry_view.setLayoutParams(params1); - ry_view.requestLayout();*/ + ry_view.requestLayout(); */ RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); params2.height = DpUtil.dp2px(270); params2.topMargin = DpUtil.dp2px(120); @@ -664,11 +736,12 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { Log.e("PK状态", "" + i); - /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); + /* + RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); params1.height = vHeight; params1.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top); params1.addRule(RelativeLayout.ALIGN_TOP); - ry_view.requestLayout();*/ + ry_view.requestLayout(); */ isPk = true; } @@ -682,41 +755,42 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { return; } int height; - if (videoLandscape == VIDEO_VERTICAL) { - height = ViewGroup.LayoutParams.MATCH_PARENT; - } else { - height = ViewGroup.LayoutParams.WRAP_CONTENT; - } - if (landscape == 2) { - Log.i(TAG, "onPrepared:还原9:16 land=" + videoLandscape); - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); - params.height = height; - params.topMargin = 0; - params.addRule(RelativeLayout.ALIGN_TOP); - mVideoView.setLayoutParams(params); - mVideoView.requestLayout(); + if (isPhysicalScreenVertical()) { + if (videoLandscape == VIDEO_VERTICAL) { + height = ViewGroup.LayoutParams.MATCH_PARENT; + } else { + height = ViewGroup.LayoutParams.WRAP_CONTENT; + } + if (landscape == 2) { + Log.i(TAG, "onPrepared:还原9:16 land=" + videoLandscape); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); + params.height = height; + params.topMargin = 0; + params.addRule(RelativeLayout.ALIGN_TOP); + mVideoView.setLayoutParams(params); + mVideoView.requestLayout(); /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); params1.height = height; params1.topMargin = 0; ry_view.setLayoutParams(params1); ry_view.requestLayout();*/ - RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); - params2.height = height; - params2.topMargin = 0; - mCover.setLayoutParams(params2); - mCover.requestLayout(); - } else { - Log.i(TAG, "onPrepared:还原16:9"); - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); - params.height = height; - params.topMargin = 0; - if (videoLandscape == VIDEO_HORIZONTAL) { - params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); - } - params.addRule(RelativeLayout.ALIGN_TOP); - mVideoView.setLayoutParams(params); - mVideoView.requestLayout(); + RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); + params2.height = height; + params2.topMargin = 0; + mCover.setLayoutParams(params2); + mCover.requestLayout(); + } else { + Log.i(TAG, "onPrepared:还原16:9"); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); + params.height = height; + params.topMargin = 0; + if (videoLandscape == VIDEO_HORIZONTAL) { + params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + } + params.addRule(RelativeLayout.ALIGN_TOP); + mVideoView.setLayoutParams(params); + mVideoView.requestLayout(); /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); params1.height = height; @@ -727,9 +801,24 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { } ry_view.setLayoutParams(params1); ry_view.requestLayout();*/ + RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); + params2.height = height; + params2.topMargin = DpUtil.dp2px(120); + mCover.setLayoutParams(params2); + mCover.requestLayout(); + } + } else { + Log.i(TAG, " onPrepared:还原横屏16:9 land=" + videoLandscape); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + params.topMargin = 0; + params.addRule(RelativeLayout.ALIGN_TOP); + mVideoView.setLayoutParams(params); + mVideoView.requestLayout(); + RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); - params2.height = height; - params2.topMargin = DpUtil.dp2px(120); + params2.height = ViewGroup.LayoutParams.MATCH_PARENT; + params2.topMargin = 0; mCover.setLayoutParams(params2); mCover.requestLayout(); } @@ -802,7 +891,6 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { @Override public void changeToLeft() { if (mVideoView != null) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); params.height = vHeight; // params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view); 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 93a4b95af..f9162d9b8 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -5,6 +5,7 @@ import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; import android.app.Activity; import android.app.Dialog; import android.content.Context; +import android.content.res.Configuration; import android.graphics.Outline; import android.graphics.drawable.Drawable; import android.os.Bundle; @@ -1000,8 +1001,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }).into(dr_pk_end_gif); } + } - + private boolean isPorit(){ + return true; } public static void UpPkBar(JSONArray obj, String uid, int time) { @@ -1175,6 +1178,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } + private boolean isPortrait(Context context){ + return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; + } + @Override public void init() { @@ -1412,17 +1419,27 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis gif_view = (LinearLayout) findViewById(R.id.gif_view); chat_view = (RelativeLayout) findViewById(R.id.chat_view); - int topMargin = mScreenWdith * 720 / 960 + 210; - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) chat_view.getLayoutParams(); - params.topMargin = topMargin; - chat_view.setLayoutParams(params); + if(isPortrait(mContentView.getContext())){ + int topMargin = mScreenWdith * 720 / 960 + 210; + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) chat_view.getLayoutParams(); + params.topMargin = topMargin; + chat_view.setLayoutParams(params); + RelativeLayout.LayoutParams msgLayoutLayoutParams = (RelativeLayout.LayoutParams) msgLayout.getLayoutParams(); + msgLayoutLayoutParams.topMargin = topMargin + DpUtil.dp2px(50); + msgLayout.setLayoutParams(msgLayoutLayoutParams); + voteManager.setMarginPosition(topMargin + DpUtil.dp2px(50)); + }else { + int topMargin = mScreenWdith * 190 / 960 ; + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) chat_view.getLayoutParams(); + params.topMargin = topMargin; + chat_view.setLayoutParams(params); + RelativeLayout.LayoutParams msgLayoutLayoutParams = (RelativeLayout.LayoutParams) msgLayout.getLayoutParams(); + msgLayoutLayoutParams.topMargin = topMargin + DpUtil.dp2px(50); + msgLayout.setLayoutParams(msgLayoutLayoutParams); + voteManager.setMarginPosition(topMargin + DpUtil.dp2px(50)); + } - RelativeLayout.LayoutParams msgLayoutLayoutParams = (RelativeLayout.LayoutParams) msgLayout.getLayoutParams(); - msgLayoutLayoutParams.topMargin = topMargin + DpUtil.dp2px(50); - msgLayout.setLayoutParams(msgLayoutLayoutParams); - voteManager.setMarginPosition(topMargin + DpUtil.dp2px(50)); - RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) mChatRecyclerView.getLayoutParams(); params1.topMargin = DpUtil.dp2px(65); mChatRecyclerView.setLayoutParams(params1); 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 ff45c40c0..68694ce70 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -520,6 +520,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } }; + //屏幕方向改变 + public void onConfigureChange() { + + } + /** * 新进入房间接口 */ @@ -1125,7 +1130,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onConfigurationChanged(Configuration newConfig) { - + mLivePlayViewHolder.onConfigureChange(); } @Override diff --git a/live/src/main/res/layout-land/view_live_play_sw.xml b/live/src/main/res/layout-land/view_live_play_sw.xml index 72c84372f..0d9d18ec8 100644 --- a/live/src/main/res/layout-land/view_live_play_sw.xml +++ b/live/src/main/res/layout-land/view_live_play_sw.xml @@ -18,7 +18,7 @@ @@ -31,7 +31,6 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /> - @@ -47,8 +46,7 @@ + android:layout_height="match_parent"> +