package com.ecom.park_jy;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.HashMap;
import java.util.List;

import static com.ecom.park_jy.Start.postion_box;

public class Skin_Road_list_Fragment_Adapter extends BaseAdapter {
    private List<HashMap<String,String>> list;
    private Context context;
    private int[] type;
    private int x = postion_box;


    public Skin_Road_list_Fragment_Adapter(Context context,List<HashMap<String,String>> list, int[] type){
        this.context = context;
        this.list = list;
        this.type = type;

    }

    @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) {
        String n = list.get(position).get("data");
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = null;
        view = inflater.inflate(R.layout.skin_road_list_fragment_adapter,null);
        String[] item = n.split("\n");
        //RelativeLayout layout = (RelativeLayout)view.findViewById(R.id.relat);
        TextView t13 = (TextView)view.findViewById(R.id.textView13);
        System.out.println(item[0].split(" ")[0].length() == 5);
        if(item[0].split(" ")[0].length() == 5){
            t13.setText(item[0].substring(1,5));
        }else if(item[0].split(" ")[0].equals("")){
            t13.setText(" ");
        }else{
            t13.setText(item[0].substring(0,4));
        }
        return view;
    }
}
