package com.swiftcleaner.chovey.view.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

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

import com.swiftcleaner.chovey.R;
import com.swiftcleaner.chovey.model.bean.CleanFileBean;
import com.swiftcleaner.chovey.model.bean.SimilarBean;

import java.util.List;

/**
 * 作者：马海钊
 * 时间：2024/12/18 14:05
 * 功能：
 */
public class SimilarPhotosAdapter extends RecyclerView.Adapter<SimilarPhotosAdapter.ViewHolder> {
    List<SimilarBean> list;
    private OnItemClickListener listener;

    public SimilarPhotosAdapter(List<SimilarBean> list, OnItemClickListener listener) {
        this.list = list;
        this.listener = listener;
    }

    @NonNull
    @Override
    public SimilarPhotosAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_similar_photo_recy_list, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull SimilarPhotosAdapter.ViewHolder holder, int position) {
        SimilarBean similarBean = list.get(position);
        if (similarBean!=null){
            holder.position_id.setText("Group "+(position+1));
//            ItemSimilarPhotosAdapter similarPhotosAdapter = new ItemSimilarPhotosAdapter(holder.itemView.getContext(), similarBean.getItems());
//            holder.listView.setAdapter(similarPhotosAdapter);

        }


    }

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

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView position_id;
        ListView listView;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            position_id=itemView.findViewById(R.id.item_similar_photos_list_position);
            listView=itemView.findViewById(R.id.item_similar_photos_listview);
        }
    }

    public interface OnItemClickListener {
        void onItemClick(CleanFileBean fileBean);
    }
}
