package com.rehome.meetingbook.adapter.base;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.rehome.meetingbook.R;
import com.rehome.meetingbook.adapter.MyAdapter;
import com.rehome.meetingbook.bean.AppointmentResultBean;
import com.rehome.meetingbook.databinding.AdapterAppointmentResultBinding;

import java.util.List;

/**
 * Create By HuangWenFei
 * 创建日期：2022-12-06 14:24
 * 描述：
 */
public class AppointmentResultAdapter extends MyAdapter<AdapterAppointmentResultBinding> {

    private List<AppointmentResultBean.RowsBean> datas;
    private final Context context;

    public AppointmentResultAdapter(Context context, List<AppointmentResultBean.RowsBean> datas) {
        super(context);
        this.datas = datas;
        this.context=context;
        //Log.i("app", GsonUtils.GsonString(datas));
    }

    @Override
    protected void handleData(int position, AdapterAppointmentResultBinding binding) {
        AppointmentResultBean.RowsBean bean = (AppointmentResultBean.RowsBean) getItem(position);

        if ((position + 1) % 2 == 0) {
            binding.ll.setBackgroundColor(context.getResources().getColor(R.color.itemColor));
        } else {
            binding.ll.setBackgroundColor(context.getResources().getColor(R.color.white));
        }

        binding.tvYyrq.setText(bean.getYyrq());
        binding.tvKsms.setText(bean.getPsmodelname());
        binding.tvXm.setText(bean.getYyrxm());
        binding.tvCbsfzr.setText(bean.getXxfzrname());

        binding.tvYyType.setText(bean.getYylx());
        binding.tvCbsname.setText(bean.getCbsname());
        binding.tvPxrName.setText(bean.getXm());
        binding.tvYydj.setText(bean.getPszb());

        binding.tvPsbm.setText(bean.getPsbm());
        binding.tvPsbz.setText(bean.getPsbz());
        binding.tvIszzpfzr.setText(bean.getIszzpfzr());
        binding.tvIsys.setText(bean.getIsys());

        binding.tvIssendrl.setText(bean.getIssendrl());
        binding.tvShstate.setText(bean.getShstate());
        binding.tvShsj.setText(bean.getShsj());
    }

    @Override
    protected AdapterAppointmentResultBinding getBinding(LayoutInflater inflater, ViewGroup parent) {
        return AdapterAppointmentResultBinding.inflate(inflater, parent, false);
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
}
