[add] adapter
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,6 @@ public class V2XShareEventsFragment extends MvpFragment<V2XShareEventsFragment,
|
||||
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
loadingView = mRootView.findViewById(R.id.network_loading_imageview);
|
||||
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mogo.module.v2x.listener;
|
||||
|
||||
public interface VideoAdapterCallBack {
|
||||
/*
|
||||
* 道路视频播放
|
||||
* */
|
||||
void videoPlayWithVideoUrl(String videoUrl);
|
||||
|
||||
void closeVideoWindow();
|
||||
}
|
||||
@@ -3,12 +3,16 @@ package com.mogo.module.v2x.scenario.scene.road;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.TextureView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.map.IDestroyable;
|
||||
import com.mogo.module.common.entity.MarkerExploreWayItem;
|
||||
import com.mogo.module.common.entity.V2XEventShowEntity;
|
||||
@@ -16,7 +20,9 @@ import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.SimpleCoverVideoPlayer;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.adapter.V2XRoadVideoAdapter;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.listener.VideoAdapterCallBack;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XWindow;
|
||||
import com.mogo.utils.BitmapHelper;
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
|
||||
@@ -26,15 +32,14 @@ import java.util.ArrayList;
|
||||
import static com.mogo.module.v2x.VideoInitKt.initVideo;
|
||||
|
||||
|
||||
public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, IDestroyable {
|
||||
public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, IDestroyable, VideoAdapterCallBack {
|
||||
|
||||
private static final String TAG = "V2XRoadVideoWindow";
|
||||
private RecyclerView roadVideoRecyclerView;
|
||||
V2XRoadVideoAdapter mV2XRoadVideoAdapter;
|
||||
private V2XWindowStatusListener mV2XWindowStatusListener;
|
||||
private SimpleCoverVideoPlayer simpleCoverVideoPlayer;
|
||||
private ImageView closeImage;
|
||||
private ImageView mThumbnailImageView;
|
||||
private ImageView windowPalyImageView;
|
||||
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public V2XRoadVideoWindow() {
|
||||
this(V2XServiceManager.getContext(), null);
|
||||
@@ -42,35 +47,30 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
||||
|
||||
public V2XRoadVideoWindow(Context context) {
|
||||
this(context, null);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public V2XRoadVideoWindow(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public V2XRoadVideoWindow(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
LayoutInflater.from(context).inflate(R.layout.window_road_video, this);
|
||||
simpleCoverVideoPlayer = this.findViewById(R.id.roadVideoView);/*播放器*/
|
||||
TextureView textureView = findViewById(R.id.tex);
|
||||
windowPalyImageView = findViewById(R.id.window_video_play);/*播放键*/
|
||||
mThumbnailImageView = findViewById(R.id.thumbnail_image);/*第一帧图片*/
|
||||
// closeImage = findViewById(R.id.roadVideoClose);
|
||||
// closeImage.setOnClickListener(v -> {
|
||||
// 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() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
) {
|
||||
|
||||
@@ -1,71 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/window_road_video"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#99000000"
|
||||
android:paddingStart="@dimen/module_main_v2x_animation_width">
|
||||
|
||||
<com.mogo.module.v2x.view.RoundLayout
|
||||
android:id="@+id/rlRoadEventList"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/video_recycleview"
|
||||
tools:listitem="@layout/window_road_video_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/dp_30"
|
||||
app:roundLayoutRadius="@dimen/dp_28">
|
||||
|
||||
<com.mogo.module.v2x.SimpleCoverVideoPlayer
|
||||
android:id="@+id/roadVideoView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="visible" />
|
||||
<TextureView
|
||||
android:id="@+id/tex"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/live_video_progress_bar_loading_color"
|
||||
android:clickable="false"
|
||||
android:layout_marginBottom="@dimen/dp_200"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
</TextureView>
|
||||
|
||||
<com.mogo.service.imageloader.MogoImageView
|
||||
android:id="@+id/thumbnail_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/v2x_bg_big_image_dark"
|
||||
android:visibility="visible"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<ImageView
|
||||
android:id="@+id/window_video_play"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="visible"
|
||||
android:src="@drawable/v2x_icon_event_play"/>
|
||||
</com.mogo.module.v2x.view.RoundLayout>
|
||||
<ImageView
|
||||
android:id="@+id/roadVideoClose"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/rlRoadEventList"
|
||||
android:layout_alignRight="@+id/rlRoadEventList"
|
||||
android:src="@drawable/v2x_panel_close" />
|
||||
|
||||
<!-- <androidx.recyclerview.widget.RecyclerView-->
|
||||
<!-- android:id="@+id/tanlu_rloop_recycleview"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- tools:listitem="@layout/tanlu_item_main_media_recycler_new"-->
|
||||
<!-- />-->
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -17,19 +17,6 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="visible" />
|
||||
<!-- <TextureView-->
|
||||
<!-- android:id="@+id/roadVideoView"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- android:background="@color/live_video_progress_bar_loading_color"-->
|
||||
<!-- android:clickable="false"-->
|
||||
<!-- android:layout_marginBottom="@dimen/dp_200"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toTopOf="parent">-->
|
||||
|
||||
<!-- </TextureView>-->
|
||||
|
||||
<com.mogo.service.imageloader.MogoImageView
|
||||
android:id="@+id/thumbnail_image"
|
||||
|
||||
Reference in New Issue
Block a user