package com.ygtx.emcs.activity.adapter;

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

import com.ygtx.emcs.R;
import com.ygtx.emcs.activity.model.WmPackage;

import java.util.List;

public class StockPackingHistoryViewAdapter extends BaseAdapter {
    private List<WmPackage> mList;
    private Context mContext;
    private LayoutInflater mLayoutInflater;

    public StockPackingHistoryViewAdapter(List<WmPackage> list, Context context) {
        this.mList=list;
        this.mContext=context;
        this.mLayoutInflater=LayoutInflater.from(context);
    }


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

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

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


    @Override
    public View getView(int position, View view, ViewGroup parent) {
        MainHolder mainHolder = null;
        final WmPackage wmPackage = mList.get(position);
        if (view == null) {
            view=mLayoutInflater.inflate(R.layout.ygtx_stock_packing_history_item,null);
            mainHolder = new MainHolder();
            mainHolder.tv_index = view.findViewById(R.id.tv_index);
            mainHolder.tv_package_code = view.findViewById(R.id.tv_package_code);
            view.setTag(mainHolder);
        }else{
            mainHolder= (MainHolder) view.getTag();
        }
        mainHolder.tv_index.setText(wmPackage.getAttr1());
        mainHolder.tv_package_code.setText(wmPackage.getPackageCode());
        return view;
    }

    static class MainHolder {
        public TextView tv_index;
        public TextView tv_package_code;
    }

}
