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 a3e60e80c..677c85fe0 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -192,6 +192,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { @Override public synchronized void setLiveBeanLandscape(int landscape) { + this.landscape = landscape; if (landscape == 2) { Log.i("收到socket--->", "还原9:16"); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); @@ -454,53 +455,53 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } else { height = DpUtil.dp2px(285); } -// if (landscape == 2) { -// Log.i("收到socket--->", "还原9:16"); -// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); -// params.height = height; -// params.topMargin = 0; -// 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; -// params1.topMargin = 0; -// params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); -// 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 { -// 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; -// params1.topMargin = 0; -// params1.addRule(RelativeLayout.ALIGN_TOP); -// if (videoLandscape == VIDEO_HORIZONTAL) { -// params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); -// } -// 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(); -// } + if (landscape == 2) { + Log.i("收到socket--->", "还原9:16"); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); + params.height = height; + params.topMargin = 0; + 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; + params1.topMargin = 0; + params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + 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 { + 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; + params1.topMargin = 0; + params1.addRule(RelativeLayout.ALIGN_TOP); + if (videoLandscape == VIDEO_HORIZONTAL) { + params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + } + 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(); + } } @Override @@ -514,24 +515,24 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } @Override - public void setPkEndview() { + public synchronized void setPkEndview() { Log.i("收收收", landscape + ""); -// if (landscape == 2) { -// Log.i("收到socket--->", "还原9:16"); -// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); -// params.height = RelativeLayout.LayoutParams.MATCH_PARENT; -// params.topMargin = 0; -// mVideoView.requestLayout(); -// -// } else { -// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); -// params.height = vHeight; -// params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); -// params.addRule(RelativeLayout.ALIGN_TOP); -// mVideoView.requestLayout(); -// } + if (landscape == 2) { + Log.i("收到socket--->", "还原9:16"); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); + params.height = RelativeLayout.LayoutParams.MATCH_PARENT; + params.topMargin = 0; + mVideoView.requestLayout(); + + } else { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); + params.height = vHeight; + params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + params.addRule(RelativeLayout.ALIGN_TOP); + mVideoView.requestLayout(); + } }