package fm.jiecao.jiecaovideoplayer; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.squareup.picasso.Picasso; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard; public class RecyclerViewVideoAdapter extends RecyclerView.Adapter<RecyclerViewVideoAdapter.MyViewHolder> { int[] videoIndexs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; private Context context; public static final String TAG = "RecyclerViewVideoAdapter"; public RecyclerViewVideoAdapter(Context context) { this.context = context; } @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { MyViewHolder holder = new MyViewHolder(LayoutInflater.from( context).inflate(R.layout.item_videoview, parent, false)); return holder; } @Override public void onBindViewHolder(MyViewHolder holder, int position) { Log.i(TAG, "onBindViewHolder [" + holder.jcVideoPlayer.hashCode() + "] position=" + position); holder.jcVideoPlayer.setUp( VideoConstant.videoUrls[0][position], JCVideoPlayer.SCREEN_LAYOUT_LIST, VideoConstant.videoTitles[0][position]); Picasso.with(holder.jcVideoPlayer.getContext()) .load(VideoConstant.videoThumbs[0][position]) .into(holder.jcVideoPlayer.thumbImageView); } @Override public int getItemCount() { return videoIndexs.length; } class MyViewHolder extends RecyclerView.ViewHolder { JCVideoPlayerStandard jcVideoPlayer; public MyViewHolder(View itemView) { super(itemView); jcVideoPlayer = (JCVideoPlayerStandard) itemView.findViewById(R.id.videoplayer); } } }