package com.danding.yang800.Adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.danding.yang800.Entity.LogisticInfo;
import com.danding.yang800.LogisticsActivity;
import com.danding.yang800.R;


public class LogisticsAdapter extends MyBaseAdapter<LogisticInfo> {


    public LogisticsAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
//        Info info = null;
//        if (convertView == null) {
        convertView = inflater
                .inflate(R.layout.logistics_adapter, null);
//            info = new Info();
        TextView logisticadapter_statusTv = (TextView) convertView.findViewById(R.id.logisticadapter_statusTv);
        TextView logisticadapter_statustimeTv = (TextView) convertView.findViewById(R.id.logisticadapter_statustimeTv);
        LinearLayout logisticadapter_infolayout = (LinearLayout) convertView
                .findViewById(R.id.logisticadapter_infolayout);
        LinearLayout lineLayout = new LinearLayout(context);
        lineLayout.setOrientation(LinearLayout.VERTICAL);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT);
        lineLayout.setLayoutParams(layoutParams);
        View view = LayoutInflater.from(context).inflate(
                R.layout.logistics_adapteradd, null);
        ImageView logisticsadapter_iv = (ImageView) view.findViewById(R.id.logisticsadapter_iv);
        View logisticsadapter_view = (View) view.findViewById(R.id.logisticsadapter_view);
        lineLayout.addView(view);
        logisticadapter_infolayout.addView(lineLayout);

        if (position == 0) {
            logisticadapter_statusTv.setTextColor(ContextCompat.getColor(context, R.color.pink));
            logisticadapter_statustimeTv.setTextColor(ContextCompat.getColor(context, R.color.pink));
            logisticsadapter_view.setVisibility(View.INVISIBLE);
            ViewGroup.LayoutParams para;
            para = logisticsadapter_iv.getLayoutParams();
            para.height = 50;
            para.width = 50;
            logisticsadapter_iv.setLayoutParams(para);
            logisticsadapter_iv.setImageDrawable(context.getResources().getDrawable(
                    R.drawable.logistics_icon));
        }
        logisticadapter_statusTv.setText(getItem(position).getStatus());
        logisticadapter_statustimeTv.setText(getItem(position).getTime());
//            convertView.setTag(info);
//        } else {
//            info = (Info) convertView.getTag();
//        }
        return convertView;
    }


//    class Info {
//        TextView logisticadapter_statusTv;
//        TextView logisticadapter_statustimeTv;
//        LinearLayout logisticadapter_infolayout;
//    }
}
