package com.example.mountaintravel.adapter;


import java.util.List;
import java.util.Map;

import com.example.mountaintravel.view.ZoomImageView;
import com.smart.gtstrvl.R;
import com.smart.gtstrvl.ZoomImageViewActivity;




import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebView.FindListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class roadAdapter extends BaseAdapter {
	List<Map<String,String>> list;
	LayoutInflater mLayoutInflater;
	Context context;
	ZoomImageView img;
	public roadAdapter(Context context, List<Map<String,String>> list) {
		super();
		this.mLayoutInflater = LayoutInflater.from(context);
		this.context = context;
		this.list = list;
	}
	public roadAdapter(Context context,ZoomImageView image) {
		super();
		this.mLayoutInflater = LayoutInflater.from(context);
		this.img=image;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = mLayoutInflater.inflate(R.layout.road_item, parent, false);
		}
		ImageView image;
		TextView mView ;
		mView = (TextView) convertView.findViewById(R.id.item_text);
		image=(ImageView) convertView.findViewById(R.id.roadImage);
		final int index=position;
		image.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				
				Intent intent=new Intent(context,ZoomImageViewActivity.class);
				intent.putExtra("index",index);
				context.startActivity(intent);
			}
		});
		String str=list.get(position).get("RuKouIdAllRoad");
		String[] strarray=str.split("a"); 
		mView.setText(strarray[0]+"\n总里程："+strarray[1]+"米\n总耗时："+strarray[2]+"分\n消耗卡路里："+strarray[3]+"卡");
		return convertView;
	}
}
