package com.example.waoperations.Shipping;

/**
 * Created by rneira on 30/08/2016.

 */

import com.example.waoperations.R;
import com.example.waoperations.R.id;
import com.example.waoperations.R.layout;

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.text.NumberFormat;

public class ShippingAdapterTransfer extends CursorAdapter {

    public ShippingAdapterTransfer(Context context, Cursor cursor) {
        super(context, cursor);
    }


    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        if (view == null) {
            LayoutInflater mInflater = (LayoutInflater)
                    context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
            view = mInflater.inflate(R.layout.drawer_list_item, null);
        }
        Typeface font = Typeface.createFromAsset(context.getAssets(), "fonts/opensans-light.ttf");
        Typeface fontbold = Typeface.createFromAsset(context.getAssets(), "fonts/opensans-semibold.ttf");

        String nombod="";

        switch (cursor.getString(7))
        {
            case "BOD_01":
                nombod="Zurquí";
                break;
            case "BOD_03":
                nombod="Zurquí";
                break;
            case "BOD_AC":
                nombod="Aceites";
                break;
        }

        TextView clientTextView = (TextView) view.findViewById(R.id.cliente);
        clientTextView.setText(""+cursor.getString(7)+ " "+nombod+"  Cantidad: "+cursor.getString(4) );
        clientTextView.setTextColor(Color.BLACK);
        clientTextView.setTypeface(fontbold);
        clientTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);

        TextView profile = (TextView) view.findViewById(R.id.puesto);
        profile.setText("Pedido Compra: "+cursor.getString(2)+" "+cursor.getString(9));
        profile.setTextColor(Color.BLACK);
        profile.setTypeface(fontbold);
        profile.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);


    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        View view = inflater.inflate(R.layout.inventorylistsimple_item, parent, false);
        return view;
    }

}
