package com.tofly.ghrq_route.common.ui.adapter;

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

import androidx.recyclerview.widget.RecyclerView;

import com.lcp.arecyclerview.widget.ARecyclerBaseAdapter;
import com.tofly.ghrq_route.R;
import com.tofly.ghrq_route.module.uploadPhoto.domain.ReportedPhotoBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Amu on 2017/5/22.
 */

public class ReportedPhotoHistoryAdapter extends ARecyclerBaseAdapter<ReportedPhotoHistoryAdapter.MyViewHolder, ReportedPhotoBean> {

    public ReportedPhotoHistoryAdapter(Context context, List<ReportedPhotoBean> data) {
        super(context, data);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View rootView = LayoutInflater.from(mContext).inflate(R.layout.item_photo_report_history, parent, false);
        MyViewHolder viewHolder = new MyViewHolder(rootView);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, int position) {
        ReportedPhotoBean reportedPhoto = getItem(position);
        if (reportedPhoto != null) {
            holder.textReporter.setText(reportedPhoto.getUploadUserName());
            holder.textReportTime.setText(reportedPhoto.getCreateTime());
            holder.textPhotoType.setText(reportedPhoto.getPictypeName());
            holder.textUploadNote.setText(reportedPhoto.getDescription());

            if (onItemClickListener != null) {
                holder.itemView.setOnClickListener(v -> onItemClickListener.onItemClick(holder.itemView, holder.getLayoutPosition()));
            }
        }
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.text_reporter_name)
        TextView textReporter;
        @BindView(R.id.text_report_time)
        TextView textReportTime;
        @BindView(R.id.text_photo_type)
        TextView textPhotoType;
        @BindView(R.id.text_upload_note)
        TextView textUploadNote;


        MyViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
