package com.baoshi.swms.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.baoshi.swms.R;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * 盘点子项
 *
 * @author Zhendong Zhou
 * @date 2021/12/17 13:48
 */
public class CheckInventoryItem extends BaseAdapter {
    private final ArrayList<HashMap<String,String>> list;
    private final Context context;

    public CheckInventoryItem(ArrayList<HashMap<String,String>> list, Context context){
        this.list =list;
        this.context =context;
    }

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

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

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.item_check_inventory, parent, false);
        }
        HashMap<String,String> stock = list.get(position);
        ((TextView)convertView.findViewById(R.id.loc)).setText(stock.get("location"));
        ((TextView)convertView.findViewById(R.id.count)).setText(stock.get("count"));
        return convertView;
    }
}
