From 10ea7d9735e49a5855899f6115392fbf9ca3b5ac Mon Sep 17 00:00:00 2001 From: hch <16607480311@163.com> Date: Mon, 1 Apr 2024 10:46:33 +0800 Subject: [PATCH] =?UTF-8?q?fix=20[=E4=BF=AE=E5=A4=8D-=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/utils/RouteUtil.java | 10 + .../res/layout/item_comment_video_view.xml | 14 +- main/src/main/res/layout/view_homemain.xml | 4 +- video/src/main/AndroidManifest.xml | 7 + .../video/activity/VideoPlayNewActivity.java | 176 ++++++++++++++++++ .../video/views/VideoCommentViewHolder.java | 4 - .../video/views/VideoPlayViewHolder.java | 22 ++- 7 files changed, 221 insertions(+), 16 deletions(-) create mode 100644 video/src/main/java/com/yunbao/video/activity/VideoPlayNewActivity.java diff --git a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java index 331ba4f6e..e97a37b16 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -57,6 +57,15 @@ public class RouteUtil { public static final String PATH_USER_HOME = "/main/UserHomeActivity"; public static final String PATH_VIDEO_PLAY = "/video/VideoPlayActivity"; + public static final String PATH_VIDEO_NEW_PLAY = "/video/VideoPlayNewActivity"; + + /* public static void forwardVideoPlayActivity(ActiveBean bean) { + ARouter.getInstance().build(PATH_VIDEO_PLAY) + .withParcelable("ActiveBean", bean) + .withString(Constants.VIDEO_KEY, Constants.VIDEO_SINGLE) + .navigation(); + }*/ + public static void forwardUserHome(String uid) { ARouter.getInstance().build(PATH_USER_HOME) .withString(Constants.TO_UID, uid) @@ -408,4 +417,5 @@ public class RouteUtil { .withString(Constants.VIDEO_KEY, Constants.VIDEO_SINGLE) .navigation(); } + } diff --git a/common/src/main/res/layout/item_comment_video_view.xml b/common/src/main/res/layout/item_comment_video_view.xml index c8b53433a..d0b15156b 100644 --- a/common/src/main/res/layout/item_comment_video_view.xml +++ b/common/src/main/res/layout/item_comment_video_view.xml @@ -4,9 +4,12 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginLeft="10dp" + android:layout_marginTop="10dp" + android:layout_marginRight="10dp" android:background="@drawable/bg_item_comment" android:orientation="vertical" - android:paddingLeft="20dp" + android:paddingLeft="10dp" android:paddingRight="10dp" tools:ignore="MissingDefaultResource"> @@ -14,12 +17,13 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" + android:layout_marginBottom="10dp" android:orientation="horizontal"> @@ -73,7 +77,6 @@ android:id="@+id/del" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="10dp" android:padding="10dp" android:text="@string/delete" android:textColor="#777777" @@ -84,7 +87,6 @@ android:id="@+id/replyTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="10dp" android:padding="10dp" android:text="@string/reply" android:textColor="#777777" @@ -94,7 +96,6 @@ android:id="@+id/report" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="10dp" android:layout_marginRight="5dp" android:padding="10dp" android:text="@string/report" @@ -109,7 +110,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="50dp" - android:layout_marginTop="10dp" android:layout_marginRight="10dp" android:background="@drawable/bg_item_comment" android:orientation="vertical" diff --git a/main/src/main/res/layout/view_homemain.xml b/main/src/main/res/layout/view_homemain.xml index 89fbd4e24..ad5b6d75e 100644 --- a/main/src/main/res/layout/view_homemain.xml +++ b/main/src/main/res/layout/view_homemain.xml @@ -15,7 +15,7 @@ @@ -30,7 +30,7 @@ diff --git a/video/src/main/AndroidManifest.xml b/video/src/main/AndroidManifest.xml index 7f566ad06..a1efabc3f 100644 --- a/video/src/main/AndroidManifest.xml +++ b/video/src/main/AndroidManifest.xml @@ -10,6 +10,11 @@ android:screenOrientation="portrait" android:windowSoftInputMode="adjustNothing|stateAlwaysHidden" /> + diff --git a/video/src/main/java/com/yunbao/video/activity/VideoPlayNewActivity.java b/video/src/main/java/com/yunbao/video/activity/VideoPlayNewActivity.java new file mode 100644 index 000000000..f3832d2b3 --- /dev/null +++ b/video/src/main/java/com/yunbao/video/activity/VideoPlayNewActivity.java @@ -0,0 +1,176 @@ +package com.yunbao.video.activity; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.Intent; +import android.text.TextUtils; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.binioter.guideview.Guide; +import com.binioter.guideview.GuideBuilder; +import com.yunbao.common.Constants; +import com.yunbao.common.bean.ActiveBean; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.L; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SpUtil; +import com.yunbao.video.R; +import com.yunbao.video.utils.LottieComponent; +import com.yunbao.video.utils.VideoStorge; +import com.yunbao.video.views.VideoScrollViewHolder; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by cxf on 2018/11/26. + */ + +@Route(path = RouteUtil.PATH_VIDEO_PLAY) +public class VideoPlayNewActivity extends AbsVideoPlayActivity { + + private View viewBottom; + private ImageView btn_back; + + public static void forward(Context context, int position, String videoKey, int page) { + Intent intent = new Intent(context, VideoPlayNewActivity.class); + intent.putExtra(Constants.VIDEO_POSITION, position); + intent.putExtra(Constants.VIDEO_KEY, videoKey); + intent.putExtra(Constants.VIDEO_PAGE, page); + context.startActivity(intent); + } + + + public static void forwardSingle(Context context, ActiveBean videoBean) { + if (videoBean == null) { + return; + } + List list = new ArrayList<>(); + list.add(videoBean); + VideoStorge.getInstance().put(Constants.VIDEO_SINGLE, list); + Intent intent = new Intent(context, VideoPlayNewActivity.class); + intent.putExtra(Constants.VIDEO_POSITION, 0); + intent.putExtra(Constants.VIDEO_KEY, Constants.VIDEO_SINGLE); + intent.putExtra(Constants.VIDEO_PAGE, 1); + context.startActivity(intent); + } + + public static void forwardSingle(Context context, String id) { + LiveNetManager.get(context).getDynamicInfo(id, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(ActiveBean data) { + List list = new ArrayList<>(); + list.add(data); + VideoStorge.getInstance().put(Constants.VIDEO_SINGLE, list); + Intent intent = new Intent(context, VideoPlayNewActivity.class); + intent.putExtra(Constants.VIDEO_POSITION, 0); + intent.putExtra(Constants.VIDEO_KEY, Constants.VIDEO_SINGLE); + intent.putExtra(Constants.VIDEO_PAGE, 1); + context.startActivity(intent); + } + + @Override + public void onError(String error) { + + } + }); + } + + + + @Override + protected int getLayoutId() { + return R.layout.activity_video_play; + } + + @Override + protected boolean isStatusBarWhite() { + return true; + } + + @Override + protected void main() { + super.main(); + Intent intent = getIntent(); + mVideoKey = intent.getStringExtra(Constants.VIDEO_KEY); + if (TextUtils.isEmpty(mVideoKey)) { + return; + } + ActiveBean bean=intent.getParcelableExtra("ActiveBean"); + if(bean!=null){ + List list = new ArrayList<>(); + list.add(bean); + VideoStorge.getInstance().put(Constants.VIDEO_SINGLE, list); + } + int position = intent.getIntExtra(Constants.VIDEO_POSITION, 0); + int page = intent.getIntExtra(Constants.VIDEO_PAGE, 1); + mVideoScrollViewHolder = new VideoScrollViewHolder(mContext, (ViewGroup) findViewById(R.id.container), position, mVideoKey, page); + mVideoScrollViewHolder.addToParent(); + mVideoScrollViewHolder.subscribeActivityLifeCycle(); + viewBottom = findViewById(R.id.viewBottom); + viewBottom.post(new Runnable() { + @Override + public void run() { + boolean read = SpUtil.getInstance().getBooleanValue(SpUtil.READ_VIDEO_GUIDE); + if (!read) { + showGuideView(); + } + } + }); + btn_back = findViewById(R.id.btn_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + } + + + @SuppressLint("ResourceType") + public void showGuideView() { + final GuideBuilder builder1 = new GuideBuilder(); + builder1.setTargetView(viewBottom) + .setAlpha(180) + .setHighTargetCorner(20) + .setHighTargetPadding(0) + .setExitAnimationId(android.R.anim.fade_out); + builder1.setOnVisibilityChangedListener(new GuideBuilder.OnVisibilityChangedListener() { + @Override + public void onShown() { + + } + + @Override + public void onDismiss() { + SpUtil.getInstance().setBooleanValue(SpUtil.READ_VIDEO_GUIDE, true); +// Toast.makeText(VideoPlayActivity.this, "引导层消失了", Toast.LENGTH_SHORT).show(); + } + }); + + builder1.addComponent(new LottieComponent()); + Guide guide = builder1.createGuide(); + guide.setShouldCheckLocInWindow(false); + guide.show(VideoPlayNewActivity.this); + + } + + @Override + public void onBackPressed() { + release(); + super.onBackPressed(); + } + + + @Override + protected void onDestroy() { + release(); + super.onDestroy(); + L.e("VideoPlayActivity------->onDestroy"); + } + + +} diff --git a/video/src/main/java/com/yunbao/video/views/VideoCommentViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoCommentViewHolder.java index b3aba28ae..d9497654e 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoCommentViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoCommentViewHolder.java @@ -27,7 +27,6 @@ import com.yunbao.common.adapter.CommentVideoAdapter; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.bean.CommentBean; import com.yunbao.common.custom.CommonRefreshView; -import com.yunbao.common.custom.ItemDecoration; import com.yunbao.common.custom.MyLinearLayout3; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpUtil; @@ -36,7 +35,6 @@ import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.AbsViewHolder; -import com.yunbao.common.views.TopGradual; import com.yunbao.live.activity.LiveReportActivity; import com.yunbao.video.R; import com.yunbao.video.activity.AbsVideoCommentActivity; @@ -129,8 +127,6 @@ public class VideoCommentViewHolder extends AbsViewHolder implements View.OnClic mCommentNum = (TextView) findViewById(R.id.comment_num); mRefreshView = (CommonRefreshView) findViewById(R.id.refreshView); mRefreshView.setEmptyLayoutId(R.layout.view_no_data_comment); - ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 5, 0); - mRefreshView.setItemDecoration(decoration); mRefreshView.setLoadMoreEnable(false); mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false) { @Override diff --git a/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java index a7b207c0b..50a3f12ed 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java @@ -46,7 +46,6 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList public VideoPlayViewHolder(Context context, ViewGroup parentView) { super(context, parentView); - } @Override @@ -58,7 +57,7 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList public void init() { mCachePath = mContext.getCacheDir().getAbsolutePath(); mTXCloudVideoView = (TXCloudVideoView) findViewById(R.id.video_view); - mTXCloudVideoView.setRenderMode(TXLiveConstants.RENDER_MODE_FULL_FILL_SCREEN); + mTXCloudVideoView.setRenderMode(TXLiveConstants.RENDER_ROTATION_PORTRAIT); mPlayer = new TXVodPlayer(mContext); mTXVodPlayConfig = new TXVodPlayConfig(); mTXVodPlayConfig.setMaxCacheItems(15); @@ -87,6 +86,9 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList if (mActionListener != null) { mActionListener.onPlayBegin(txVodPlayer.getDuration()); } + if (mActionListener != null) { + mActionListener.onFirstFrame(); + } break; case TXLiveConstants.PLAY_EVT_PLAY_LOADING: //开始加载的回调 if (mActionListener != null) { @@ -111,7 +113,7 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList } break; case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取到视频宽高回调 - onVideoSizeChanged(bundle.getInt("EVT_PARAM1", 0), bundle.getInt("EVT_PARAM2", 0)); + onVideoSizeChanged( bundle.getInt("EVT_PARAM2", 0),bundle.getInt("EVT_PARAM1", 0)); break; case TXLiveConstants.PLAY_EVT_PLAY_PROGRESS: if (mActionListener != null) { @@ -133,9 +135,23 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList */ public void onVideoSizeChanged(float videoWidth, float videoHeight) { if (mTXCloudVideoView != null && videoWidth > 0 && videoHeight > 0) { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mTXCloudVideoView.getLayoutParams(); + /* + int videoViewHeight = params.height; + int videoViewWidth = params.width; + if (videoWidth < videoViewWidth && videoHeight >= videoViewHeight) { + params.width = (int) (videoViewHeight / (videoHeight / videoViewHeight)); + } else if (videoWidth > videoViewWidth && videoHeight >= videoViewHeight) { + params.width = (int) (videoViewHeight / (videoHeight / videoWidth)); + } + mTXCloudVideoView.requestLayout(); + if (mVideoCover != null && mVideoCover.getVisibility() == View.VISIBLE) { + mVideoCover.setVisibility(View.INVISIBLE); + }*/ int targetH = 0; if (videoWidth / videoHeight > 0.5625f) {//横屏 9:16=0.5625 + /*targetH = (int) (videoHeight*(videoWidth/videoHeight));*/ targetH = (int) (mTXCloudVideoView.getWidth() / videoWidth * videoHeight); } else { targetH = ViewGroup.LayoutParams.MATCH_PARENT;