package tinj.jcdv.wpky;

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

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.test.basd.smartjunkcleaner.R;

import java.util.List;

public class Lcsh extends RecyclerView.Adapter<Lcsh.GalleryViewHolder> {
    private Context context;


    private int index = 0;

    public void setPos(int index) {
        this.index = index;
    }

    private List<Mxtk> list;

    public Lcsh(Context context, List<Mxtk> list) {
        this.context = context;
        this.list = list;
    }

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

    @Override
    public void onBindViewHolder(@NonNull GalleryViewHolder holder, int position) {
        if (position < list.size()) {
            Mxtk bean = list.get(position);
            Glide.with(holder.itemView.getContext()).load(bean.getSrc()).into((ImageView) holder.itemView);
        }
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public static class GalleryViewHolder extends RecyclerView.ViewHolder {

        public GalleryViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
}