package com.sheep.gamegroup.view.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.sheep.jiuyan.samllsheep.R;

import java.util.List;

/**
 * created on：2018/9/5 on 9:18
 * created by: YSL
 * 描述:
 */
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyHolder> {
    private Context mContext;
    private List<Bitmap> mList;
    private List<Bitmap> list;
    private View view;

    public MyAdapter(Context mContext, List<Bitmap> mList, List<Bitmap> list) {
        this.mContext = mContext;
        this.mList = mList;
        this.list = list;
    }

    @NonNull
    @Override
    public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.view_image, parent, false);
        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyHolder holder, int position) {
        //   holder.imageView.setImageResource(ress[position]);

        // holder.imageView.setImageBitmap(mergeBitmap(bitmap1, bitmap2));
        if (mList.size() == 0 || list.size() == 0) {
            return;
        }
        holder.imageView.setImageBitmap(mList.get(position));
        holder.iv_er.setImageBitmap(list.get(position));
        setView(holder.relativeLayout);

    }

    @Override
    public int getItemCount() {
        return mList == null ? 0 : mList.size();
    }

    public View getView() {
        return view;
    }

    private void setView(RelativeLayout relativeLayout) {
        this.view = relativeLayout;
    }

    class MyHolder extends RecyclerView.ViewHolder {

        com.sheep.gamegroup.helper.CustomRoundAngleImageView imageView;
        ImageView iv_er;
        RelativeLayout relativeLayout;

        public MyHolder(View itemView) {
            super(itemView);
            imageView = itemView.findViewById(R.id.image);
            iv_er = itemView.findViewById(R.id.iv_er);
            relativeLayout = itemView.findViewById(R.id.layout_view);
        }
    }
}

