public class VideosAdapter extends RecyclerView.Adapter<VideosAdapter.VideoViewHolder>{
private List<VideoItem> mVideoItems;
public VideosAdapter(List<VideoItem> videoItems) {
mVideoItems = videoItems;
}
@NonNull
@Override
public VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new VideoViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_videos_container,parent,false));
}
@Override
public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) {
holder.setVideoData(mVideoItems.get(position));
}
@Override
public int getItemCount() {
return mVideoItems.size();
}
static class VideoViewHolder extends RecyclerView.ViewHolder{
VideoView mVideoView;
TextView txtTitle,txtDesc;
ProgressBar mProgressBar;
static ImageView moreoptiontovideo;
public VideoViewHolder(@NonNull View itemView) {
super(itemView);
mVideoView = itemView.findViewById(R.id.videoView);
txtTitle = itemView.findViewById(R.id.textVideoTitle);
txtDesc = itemView.findViewById(R.id.textVideoDescription);
mProgressBar = itemView.findViewById(R.id.progressBar);
moreoptiontovideo = itemView.findViewById(R.id.moreoptiontovideo);
itemView.setOnClickListener(onClick());
}
public View.OnClickListener onClick() {
Toast.makeText(moreoptiontovideo.getContext(), itemView.getId()+"TextView Clicked!", Toast.LENGTH_LONG).show();
if(itemView.getId()==R.id.moreoptiontovideo)
Toast.makeText(moreoptiontovideo.getContext(), "TextView Clicked!", Toast.LENGTH_LONG).show();
return null;
}
void setVideoData(VideoItem videoItem){
txtTitle.setText(videoItem.videoTitle);
txtDesc.setText(videoItem.videoDesc);
mVideoView.setVideoPath(videoItem.videoURL);
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mProgressBar.setVisibility(View.GONE);
mp.start();
float videoRatio = mp.getVideoWidth() / (float)mp.getVideoHeight();
float screenRatio = mVideoView.getWidth() / (float)mVideoView.getHeight();
float scale = videoRatio / screenRatio;
if (scale >= 1f){
mVideoView.setScaleX(scale);
}else {
mVideoView.setScaleY(1f / scale);
}
}
});
mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mp.start();
}
});
}
}
}
i tried above code "moreoptiontovideo" id imageview not able to click , please help someone