package com.philisense.rdgo.adapter;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.philisense.rdgo.R;
import com.philisense.rdgo.bean.MyOutBoxBean;
import com.philisense.rdgo.bean.response.WarehouseBean;
import com.philisense.rdgo.databinding.ItemDigaoBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by shaop on 2018/1/5.
 */

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

    private List<MyOutBoxBean> dataArray;
    private Context context;

    public delteAdapter(Context context) {
        this.context = context;
        dataArray = new ArrayList<>();
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ItemDigaoBinding mBindHeader = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_digao, parent, false);
        return new delteAdapter.OrderViewHolder(mBindHeader.getRoot());
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        OrderViewHolder lineViewHolder = (OrderViewHolder) holder;


        String name = dataArray.get(position).getBoxId();
        lineViewHolder.itemOrderBinding.itemName.setText(name);


    }


    @Override
    public int getItemCount() {

        if (dataArray != null) {
            return dataArray.size();
        }

        return 0;
    }

    /**
     * 添加数据
     *
     * @param data 数据
     */
    public void insertData(List<WarehouseBean.ListBean> data) {

    }

    /**
     * 初始化数据
     *
     * @param data 数据
     */
    public void setData(List<MyOutBoxBean> data) {
        dataArray = data;
        notifyDataSetChanged();
    }

    private class OrderViewHolder extends RecyclerView.ViewHolder {

        ItemDigaoBinding itemOrderBinding;

        OrderViewHolder(View view) {
            super(view);
            itemOrderBinding = DataBindingUtil.getBinding(view);
        }

    }
}

