DeliveryXrecAdapter.java 3.3 KB
package com.hh.xuetubao.adapter;

import android.content.Context;
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.TextView;

import com.hh.xuetubao.R;
import com.hh.xuetubao.bean.ResumedJobListBean;

import java.util.List;

public class DeliveryXrecAdapter extends RecyclerView.Adapter<DeliveryXrecAdapter.ViewHolder> {

    private List<ResumedJobListBean.JobListBean> mlist;
    private Context context;

    public DeliveryXrecAdapter(List<ResumedJobListBean.JobListBean> mlist, Context context) {
        this.mlist = mlist;
        this.context = context;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.activity_delivery_list, null);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
        ResumedJobListBean.JobListBean bean = mlist.get(position);
        if (bean.getJobName() != null)
            holder.jobName.setText(bean.getJobName());
        if (bean.getCompanName() != null)
            holder.company.setText(bean.getCompanName());
        if (bean.getSalary() != null)
            holder.money.setText(bean.getSalary());
        if (bean.getExprience() != null)
            holder.jiangYan.setText(bean.getExprience());
        if (bean.getEducation() != null)
            holder.xueLi.setText(bean.getEducation());
        if (bean.getAddress() != null)
            holder.address.setText(bean.getAddress());

        if (bean.getSendTime() != null) {
            holder.tv_time.setText(bean.getSendTime());
        }

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (turnTo != null)
                    turnTo.turnToActicity(mlist.get(position).getJobOid());
            }
        });

    }

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

    public class ViewHolder extends RecyclerView.ViewHolder {

        private final TextView jobName;
        private final TextView company;
        private final TextView money;
        private final TextView jiangYan;
        private final TextView xueLi;
        private final TextView address;
        private final  TextView tv_time;

        public ViewHolder(View itemView) {
            super(itemView);
            jobName = (TextView) itemView.findViewById(R.id.tv_job);
            company = (TextView) itemView.findViewById(R.id.tv_company);
            money = (TextView) itemView.findViewById(R.id.tv_money);
            jiangYan = (TextView) itemView.findViewById(R.id.tv_jingyan);
            xueLi = (TextView) itemView.findViewById(R.id.tv_xueli);
            address = (TextView) itemView.findViewById(R.id.tv_address);
            tv_time = itemView.findViewById(R.id.tv_time);
        }
    }

    private TurnTo turnTo;

    public void setTurnTo(TurnTo turnTo) {
        this.turnTo = turnTo;
    }

    public interface TurnTo {
        void turnToActicity(String jobId);
    }
}