package com.danding.yang800.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.danding.yang800.Entity.AccountDetailedInfo;
import com.danding.yang800.Entity.DetailsInfo;
import com.danding.yang800.R;
import com.zhy.autolayout.utils.AutoUtils;

public class AccountDetailedAdapter extends MyBaseAdapter<AccountDetailedInfo> {

    public AccountDetailedAdapter(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.account_detailed_adapter, null);
            info = new Info();
            info.account_detailed_adapterTv = (TextView) convertView.findViewById(R.id.account_detailed_adapterTv);
            info.account_detailed_adapterTimeTv = (TextView) convertView.findViewById(R.id.account_detailed_adapterTimeTv);
            info.account_detailed_adapterMoneyTv = (TextView) convertView.findViewById(R.id.account_detailed_adapterMoneyTv);
            info.account_detailed_adapterOrderTv = (TextView) convertView.findViewById(R.id.account_detailed_adapterOrderTv);
//            info.details_name = (TextView) convertView.findViewById(R.id.details_name);
//            info.details_price = (TextView) convertView.findViewById(R.id.details_price);
//            info.details_number = (TextView) convertView.findViewById(R.id.details_number);
            convertView.setTag(info);
            AutoUtils.autoSize(convertView);

        } else {
            info = (Info) convertView.getTag();
        }
//        Glide.with(context).load(getItem(position).getUrl()).error(R.drawable.shouye).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(info.details_image);
        info.account_detailed_adapterTv.setText(getItem(position).getOrder());
        info.account_detailed_adapterTimeTv.setText(getItem(position).getTime());
        if (getItem(position).getMoney().contains("-")){
            info.account_detailed_adapterMoneyTv.setText(getItem(position).getMoney());
        }else {
            info.account_detailed_adapterMoneyTv.setText("+"+getItem(position).getMoney());
        }
        if (getItem(position).getPackageSn().equals("")){
         info.account_detailed_adapterOrderTv.setVisibility(View.GONE);
        }else {
            info.account_detailed_adapterOrderTv.setVisibility(View.VISIBLE);
            info.account_detailed_adapterOrderTv.setText(getItem(position).getPackageSn());
        }
        info.account_detailed_adapterTimeTv.setText(getItem(position).getTime());
        info.account_detailed_adapterTv.setText(getItem(position).getOrder());
//        info.details_price.setText("￥" + getItem(position).getPrice());
//        info.details_number.setText("x" + getItem(position).getNumber());
        return convertView;
    }


    class Info {
        TextView account_detailed_adapterTv;
        TextView account_detailed_adapterTimeTv;
        TextView account_detailed_adapterMoneyTv;
        TextView account_detailed_adapterOrderTv;
    }
}
