视频适配父布局
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
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.VideoAdapterCallBack;
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
|
||||
|
||||
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_layout, 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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,34 @@
|
||||
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;
|
||||
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.mogo.module.v2x.view.SimpleCoverVideoPlayer;
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
|
||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.mogo.module.v2x.VideoInitKt.initVideo;
|
||||
import static com.shuyu.gsyvideoplayer.utils.GSYVideoType.SCREEN_MATCH_FULL;
|
||||
|
||||
|
||||
public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, IDestroyable, VideoAdapterCallBack {
|
||||
|
||||
private static final String TAG = "V2XRoadVideoWindow";
|
||||
private RecyclerView roadVideoRecyclerView;
|
||||
V2XRoadVideoAdapter mV2XRoadVideoAdapter;
|
||||
private V2XWindowStatusListener mV2XWindowStatusListener;
|
||||
private ImageView playImageView;
|
||||
private ImageView closeImage;
|
||||
@@ -47,7 +39,6 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
||||
|
||||
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
|
||||
|
||||
// private Context mContext;
|
||||
|
||||
public V2XRoadVideoWindow() {
|
||||
this(V2XServiceManager.getContext(), null);
|
||||
@@ -74,9 +65,12 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
||||
initVideo();
|
||||
playImageView = this.findViewById(R.id.window_video_play);
|
||||
simpleCoverVideoPlayer = this.findViewById(R.id.roadVideoView);
|
||||
GSYVideoType.setShowType(SCREEN_MATCH_FULL);
|
||||
//mCurrentAspectRatio
|
||||
// simpleCoverVideoPlayer.
|
||||
closeImage = this.findViewById(R.id.roadVideoClose);
|
||||
closeImage.setOnClickListener(v -> {
|
||||
|
||||
close();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -92,23 +86,9 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
||||
return;
|
||||
}
|
||||
if (path.contains(".mp4")) {
|
||||
playImageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gsyVideoOptionBuilder.setUrl(path).setCacheWithPlay(false).setPlayTag(TAG)
|
||||
.build(simpleCoverVideoPlayer);
|
||||
simpleCoverVideoPlayer.getStartButton().performClick();
|
||||
}
|
||||
|
||||
});
|
||||
simpleCoverVideoPlayer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gsyVideoOptionBuilder.setUrl(path).setCacheWithPlay(false).setPlayTag(TAG)
|
||||
.build(simpleCoverVideoPlayer);
|
||||
simpleCoverVideoPlayer.getStartButton().performClick();
|
||||
}
|
||||
});
|
||||
gsyVideoOptionBuilder.setUrl(path).setCacheWithPlay(false).setPlayTag(TAG)
|
||||
.build(simpleCoverVideoPlayer);
|
||||
simpleCoverVideoPlayer.getStartButton().performClick();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.module.v2x
|
||||
package com.mogo.module.v2x.view
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
@@ -34,9 +34,9 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer {
|
||||
|
||||
override fun init(context: Context) {
|
||||
super.init(context)
|
||||
coverImage = findViewById(R.id.thumbnail_image)
|
||||
coverImage = findViewById(R.id.thumbImage)
|
||||
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)
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user