diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/V2XRoadVideoAdapter.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/V2XRoadVideoAdapter.java new file mode 100644 index 0000000000..9488f14e61 --- /dev/null +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/V2XRoadVideoAdapter.java @@ -0,0 +1,89 @@ +package com.mogo.module.v2x.adapter; + +import android.content.Context; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.mogo.module.v2x.R; +import com.mogo.module.v2x.SimpleCoverVideoPlayer; +import com.mogo.module.v2x.listener.AdapterCallback; +import com.mogo.module.v2x.listener.VideoAdapterCallBack; +import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder; + +import java.util.ArrayList; + +public class V2XRoadVideoAdapter extends RecyclerView.Adapter { + private static final String TAG = "V2XRoadVideoAdapter"; + private final LayoutInflater shareLayoutInflater; + private VideoAdapterCallBack mCallback; + private SimpleCoverVideoPlayer simpleCoverVideoPlayer; + private Context mContext; + + private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder(); + + public V2XRoadVideoAdapter(Context context, VideoAdapterCallBack callback) { + mContext = context; + shareLayoutInflater = LayoutInflater.from(context); + mCallback = callback; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View v = shareLayoutInflater.inflate(R.layout.window_road_video_item, parent, + false); + RoadVideoVH holder = new RoadVideoVH(v); + return holder; + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + Log.d(TAG, "onBindViewHolder"); + } + + @Override + public int getItemCount() { + return 1; + } + + public void videoPlayWithVideoUrl(String videoUrl) { +// gsyVideoOptionBuilder.setUrl(videoUrl).setCacheWithPlay(false).setPlayTag(TAG) +// .build(simpleCoverVideoPlayer); +// simpleCoverVideoPlayer.getStartButton().performClick(); + } + + public class RoadVideoVH extends RecyclerView.ViewHolder { + private ImageView playImageView; + private ImageView closeImage; + + public RoadVideoVH(@NonNull View itemView) { + super(itemView); + playImageView = itemView.findViewById(R.id.window_video_play); + simpleCoverVideoPlayer = itemView.findViewById(R.id.roadVideoView); + closeImage = itemView.findViewById(R.id.roadVideoClose); + + playImageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mCallback.videoPlayWithVideoUrl(""); + } + + }); + simpleCoverVideoPlayer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mCallback.videoPlayWithVideoUrl(""); + } + }); + closeImage.setOnClickListener(v -> { + mCallback.closeVideoWindow(); + }); + } + } +} diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XShareEventsFragment.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XShareEventsFragment.java index d1f9b455a4..bc638a88b4 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XShareEventsFragment.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XShareEventsFragment.java @@ -69,7 +69,6 @@ public class V2XShareEventsFragment extends MvpFragment { -// close(); -// }); -// simpleCoverVideoPlayer.setOnClickListener(v -> { -// mThumbnailImageView.setVisibility(View.GONE); -//// if (simpleCoverVideoPlayer.isPlaying()) { -//// videoPause(); -//// } else { -//// videoResume(); -//// } -// }); + mContext = context; + LayoutInflater.from(mContext).inflate(R.layout.window_road_video, this); + initVideo(); + roadVideoRecyclerView = findViewById(R.id.video_recycleview); + mV2XRoadVideoAdapter = new V2XRoadVideoAdapter(mContext, this); + roadVideoRecyclerView.setAdapter(mV2XRoadVideoAdapter); + LinearLayoutManager linearLayoutManager = + new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false); + roadVideoRecyclerView.setLayoutManager(linearLayoutManager); } @Override @@ -85,74 +85,12 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID return; } if (path.contains(".mp4")) { - videoViewStartWithPath(path); - -// mVideoView.setOnCompletionListener(mediaPlayer -> { -// Logger.w(MODULE_NAME, "视频播放结束..."); -// videoPlayEnd(path); -// }); - + mV2XRoadVideoAdapter.videoPlayWithVideoUrl(path); } } } - /* - * 视频开始播放 - * */ - private void videoViewStartWithPath(String path) { - initVideo(); - simpleCoverVideoPlayer.setVisibility(View.VISIBLE); - //加载封面图 - simpleCoverVideoPlayer.loadCoverImage(path, getContext()); - gsyVideoOptionBuilder.setUrl(path).setCacheWithPlay(false).setPlayTag(TAG) - .build(simpleCoverVideoPlayer); - simpleCoverVideoPlayer.getStartButton().performClick(); - -// simpleCoverVideoPlayer.setOnPreparedListener(mediaPlayer -> { -// mThumbnailImageView.setVisibility(View.GONE); -// windowPalyImageView.setVisibility(View.GONE); -// }); -// simpleCoverVideoPlayer.start(); - } - - /* - * 视频暂停播放 - * */ - private void videoPause() { -// simpleCoverVideoPlayer.pause(); - windowPalyImageView.setVisibility(View.VISIBLE); - windowPalyImageView.setOnClickListener(v -> { - videoResume(); - }); - } - - /* - * 视频暂停后继续播放 - * */ - private void videoResume() { -// mThumbnailImageView.setVisibility(View.INVISIBLE); -// mVideoView.resume(); - } - - /* - * 视频播放结束 - * */ - private void videoPlayEnd(String path) { - Bitmap bitmap = BitmapHelper.getVideoThumbnail(path); - mThumbnailImageView.setVisibility(View.VISIBLE); - mThumbnailImageView.setImageBitmap(bitmap); - - windowPalyImageView.setVisibility(View.VISIBLE); - windowPalyImageView.setOnClickListener(v -> { - videoViewStartWithPath(path); - - }); - if (mV2XWindowStatusListener != null) { - mV2XWindowStatusListener.onViewClose(); - } - } - @Override public void close() { //移除窗体 @@ -175,4 +113,14 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID public void destroy() { } + + @Override + public void videoPlayWithVideoUrl(String videoUrl) { + + } + + @Override + public void closeVideoWindow() { + + } } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SimpleCoverVideoPlayer.kt b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SimpleCoverVideoPlayer.kt index 77cb118d27..cd246a5f61 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SimpleCoverVideoPlayer.kt +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SimpleCoverVideoPlayer.kt @@ -36,7 +36,7 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer { super.init(context) coverImage = findViewById(R.id.thumbnail_image) start = findViewById(R.id.start) - fullscreen = findViewById(R.id.fullscreen) +// fullscreen = findViewById(R.id.fullscreen) if (mThumbImageViewLayout != null && (mCurrentState == -1 || mCurrentState == GSYVideoView.CURRENT_STATE_NORMAL || mCurrentState == GSYVideoView.CURRENT_STATE_ERROR) ) { diff --git a/modules/mogo-module-v2x/src/main/res/layout/window_road_video.xml b/modules/mogo-module-v2x/src/main/res/layout/window_road_video.xml index 6c0898cf0f..ce6f2f91c1 100644 --- a/modules/mogo-module-v2x/src/main/res/layout/window_road_video.xml +++ b/modules/mogo-module-v2x/src/main/res/layout/window_road_video.xml @@ -1,71 +1,17 @@ - - - - - - - - - - - - - - - - - - + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/modules/mogo-module-v2x/src/main/res/layout/window_road_video_item.xml b/modules/mogo-module-v2x/src/main/res/layout/window_road_video_item.xml index cbfe283897..f10bc55235 100644 --- a/modules/mogo-module-v2x/src/main/res/layout/window_road_video_item.xml +++ b/modules/mogo-module-v2x/src/main/res/layout/window_road_video_item.xml @@ -17,19 +17,6 @@ android:layout_height="match_parent" android:layout_centerInParent="true" android:visibility="visible" /> - - - - - - - - - - - - -