package com.tenlionsoft.baselib.core.widget.base;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.tenlionsoft.baselib.R;

import java.util.List;

/**
 * 作者 : Adam on 2018/11/14.
 * 邮箱 : itgaojian@163.com
 * 描述 : <功能描述>
 */
public class BaseShowVideoAdapter extends BaseRecyclerAdapter<String, BaseVideoHolder> {
    public BaseShowVideoAdapter(Context ctx, List<String> list) {
        super(ctx, list);
    }

    @Override
    public BaseVideoHolder createHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(mContext)
            .inflate(R.layout.item_show_video, parent, false);
        return new BaseVideoHolder(itemView);
    }

    @Override
    public void bindHolder(BaseVideoHolder showPhotoHolder, int i) {
        RequestOptions transform = new RequestOptions()
            .error(R.drawable.ic_play_white_icon)
            .placeholder(R.drawable.ic_play_white_icon)
            .transform(new GlideRoundTransform(mContext, 5));
        Glide.with(mContext)
            .load(R.drawable.ic_play_white_icon)
            .apply(transform)
            .into(showPhotoHolder.mIvPhoto);
        if (listener != null) {
            showPhotoHolder.itemView.setOnClickListener(v -> listener.clickListener(mData.get(i), i));
        }
    }

    public interface OnItemClick {
        void clickListener(String data, int pos);
    }

    private OnItemClick listener;

    public void setOnItemClickListener(OnItemClick listener) {
        this.listener = listener;
    }
}

