package com.sjkj.appthreefloor_tsgz.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.sjkj.appthreefloor_tsgz.R;
import com.sjkj.appthreefloor_tsgz.bean.ImageBean;
import com.sjkj.appthreefloor_tsgz.databinding.ItemVideoDelListBinding;
import com.sjkj.appthreefloor_tsgz.utils.AppSystemUtils;
import com.sjkj.base_lib.adapter.BaseRecAdapter;

import java.util.List;

public class VideoDelAdapter extends BaseRecAdapter<ImageBean, ItemVideoDelListBinding> {

    public VideoDelAdapter(Context context) {
        super(context);
    }

    public VideoDelAdapter(Context context, List<ImageBean> list) {
        super(context, list);
    }

    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.item_video_del_list;
    }

    @Override
    protected void onBindItem(ItemVideoDelListBinding binding, ImageBean bean, int position) {
        binding.setModel(bean);
        binding.executePendingBindings();
       //binding.ivVideo.setImageBitmap(VideoUtil.createVideoThumbnail(bean.getRealUrl()));
        if (AppSystemUtils.isGhb()) {
            binding.rlVideo.setLayoutParams(new RelativeLayout.LayoutParams(300, 300));
            ViewGroup.LayoutParams params = binding.ivVideo.getLayoutParams();
            params.height = 280;
            params.width = 280;
            binding.ivVideo.setLayoutParams(params);
            ViewGroup.LayoutParams params_del = binding.ivIcon.getLayoutParams();
            params_del.height = 75;
            params_del.width = 75;
            binding.ivIcon.setLayoutParams(params_del);
        }
        Glide.with(context)
                .setDefaultRequestOptions(
                        new RequestOptions()
                                .frame(1000)
                                .centerCrop()
                )
                .load(bean.getRealUrl())
                .into(binding.ivVideo);


        binding.deleteIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (list != null && list.size() > 0) {
                    list.remove(position);
                    notifyDataSetChanged();
                }
            }
        });
    }


}
