package com.ygtx.emcs.activity.adapter;

import android.content.Context;
import android.graphics.Color;
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.StockLineModel;
import com.ygtx.emcs.activity.model.WmPackageLine;

import java.math.BigDecimal;
import java.util.ArrayList;

public class StockPackingItemViewAdapter extends BaseAdapter {
    private ArrayList<WmPackageLine> mList;
    private Context mContext;
    private LayoutInflater mLayoutInflater;

    public StockPackingItemViewAdapter(ArrayList<WmPackageLine> 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 WmPackageLine wmPackageLine = mList.get(position);
        if (view == null) {
            view=mLayoutInflater.inflate(R.layout.ygtx_stock_packing_item,null);
            mainHolder = new MainHolder();
            mainHolder.tv_item_spec = view.findViewById(R.id.tv_item_spec);
            mainHolder.tv_product_code = view.findViewById(R.id.tv_product_code);
            mainHolder.qty = view.findViewById(R.id.tv_qty);
            mainHolder.tv_product_name = view.findViewById(R.id.tv_product_name);
            mainHolder.tv_stock_num = view.findViewById(R.id.tv_stock_num);
            view.setTag(mainHolder);
        }else{
            mainHolder= (MainHolder) view.getTag();
        }
        mainHolder.tv_item_spec.setText(wmPackageLine.getSpecification());
        mainHolder.tv_product_code.setText(wmPackageLine.getItemCode());
        mainHolder.qty.setText(wmPackageLine.getQuantityPackage().toString());
        mainHolder.tv_product_name.setText(wmPackageLine.getItemName());
        return view;
    }

    static class MainHolder {
        public TextView tv_product_code;
        public TextView qty;
        public TextView tv_item_spec;
        public TextView tv_product_name;
        public TextView tv_stock_num;
    }

}
