package com.mq.zhuangchefaka;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mq.zhuangchefaka.db.ZhuangCheEntity;

import java.util.List;

/**
 * 创建人 mQ
 * 创建时间 2019/8/14 0014 19:29
 * 文件名称 LogAdapter
 * 说明:
 **/
public class LogAdapter extends BaseQuickAdapter<ZhuangCheEntity, BaseViewHolder> {

    public CallBack mCallBack;

    public LogAdapter(@Nullable List<ZhuangCheEntity> data) {
        super(R.layout.item_log, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ZhuangCheEntity item) {
        helper
                .setText(R.id.tv_inbound_code, item.inbound_code)
                .setText(R.id.tv_train_code, item.train_code)
                .setText(R.id.tv_gain, item.grain)
                .setText(R.id.tv_platform, item.platform_name)
                .setText(R.id.tv_position, item.position_name)
                .setText(R.id.tv_car, item.car)
                .setText(R.id.tv_entd, item.entd)
                .setText(R.id.tv_load_time, item.load_time)
        ;

        helper.getView(R.id.layout_item).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //查看
                if (mCallBack != null) {
                    mCallBack.onLookListener(item);
                }
            }
        });
        helper.getView(R.id.btn_look).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //查看
                if (mCallBack != null) {
                    mCallBack.onLookListener(item);
                }
            }
        });
        helper.getView(R.id.btn_card).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //补卡
                if (mCallBack != null) {
                    mCallBack.onCardListener(item);
                }
            }
        });

    }

    public void setCallBack(CallBack callBack) {
        mCallBack = callBack;
    }

    public interface CallBack {
        public void onLookListener(ZhuangCheEntity entity);

        public void onCardListener(ZhuangCheEntity entity);
    }
}
