// Path: src/org/osmdroid/utils/BonusPackHelper.java
// public class BonusPackHelper {
// 
// 	/** Log tag. */
// 	public static final String LOG_TAG = "BONUSPACK";
// 
// 	/** User agent sent to services by default */
// 	public static final String DEFAULT_USER_AGENT = "OsmBonusPack/1";
// 
// 	/**
// 	 * @return true if the device is the emulator, false if actual device.
// 	 */
// 	public static boolean isEmulator() {
// 		//return Build.MANUFACTURER.equals("unknown");
// 		return ("google_sdk".equals(Build.PRODUCT) || "sdk".equals(Build.PRODUCT));
// 	}
// 
// 	/**
// 	 * @param connection
// 	 *            ...
// 	 * @return the whole content of the http request, as a string
// 	 */
// 	private static String readStream(HttpConnection connection) {
// 		String result = connection.getContentAsString();
// 		return result;
// 	}
// 
// 	/**
// 	 * sends an http request, and returns the whole content result in a String.
// 	 * 
// 	 * @param url
// 	 *            ...
// 	 * @return the whole content, or null if any issue.
// 	 */
// 	public static String requestStringFromUrl(String url) {
// 		HttpConnection connection = new HttpConnection();
// 		connection.doGet(url);
// 		String result = readStream(connection);
// 		connection.close();
// 		return result;
// 	}
// 
// 	/**
// 	 * requestStringFromPost: do a post request to a url with name-value pairs,
// 	 * and returns the whole content result in a String.
// 	 * 
// 	 * @param url
// 	 *            ...
// 	 * @param nameValuePairs
// 	 *            ...
// 	 * @return the content, or null if any issue.
// 	 */
// 	public static String requestStringFromPost(String url, List<NameValuePair> nameValuePairs) {
// 		HttpConnection connection = new HttpConnection();
// 		connection.doPost(url, nameValuePairs);
// 		String result = readStream(connection);
// 		connection.close();
// 		return result;
// 	}
// 
// 	/**
// 	 * Loads a bitmap from a url.
// 	 * 
// 	 * @param url
// 	 *            ...
// 	 * @return the bitmap, or null if any issue.
// 	 */
// 	public static Bitmap loadBitmap(String url) {
// 		Bitmap bitmap = null;
// 		try {
// 			InputStream is = (InputStream) new URL(url).getContent();
// 			bitmap = BitmapFactory.decodeStream(new FlushedInputStream(is));
// 			//Alternative providing better handling on loading errors?
// 			/* Drawable d = Drawable.createFromStream(new
// 			 * FlushedInputStream(is), null); if (is != null) is.close(); if (d
// 			 * != null) bitmap = ((BitmapDrawable)d).getBitmap(); */
// 		} catch (FileNotFoundException e) {
// 			//log.debug("image not available: " + url);
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 			return null;
// 		}
// 		return bitmap;
// 	}
// 
// 	/**
// 	 * Workaround on Android issue see
// 	 * http://stackoverflow.com/questions/4601352
// 	 * /createfromstream-in-android-returning-null-for-certain-url
// 	 */
// 	static class FlushedInputStream extends FilterInputStream {
// 		public FlushedInputStream(InputStream inputStream) {
// 			super(inputStream);
// 		}
// 
// 		@Override
// 		public long skip(long n) throws IOException {
// 			long totalBytesSkipped = 0L;
// 			while (totalBytesSkipped < n) {
// 				long bytesSkipped = in.skip(n - totalBytesSkipped);
// 				if (bytesSkipped == 0L) {
// 					int byteValue = read();
// 					if (byteValue < 0)
// 						break; // we reached EOF
// 
// 					bytesSkipped = 1; // we read one byte
// 				}
// 				totalBytesSkipped += bytesSkipped;
// 			}
// 			return totalBytesSkipped;
// 		}
// 	}
// }


import org.oscim.app.R;
import org.oscim.core.BoundingBox;
import org.oscim.core.GeoPoint;
import org.osmdroid.utils.BonusPackHelper;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.view.View;
import android.widget.ImageView;
package org.osmdroid.location;



/**
 * Point of Interest. Exact content may depend of the POI provider used.
 * 
 * @see NominatimPOIProvider
 * @see GeoNamesPOIProvider
 * @author M.Kergall
 */
public class POI {

	/** IDs of POI services */
	public static int POI_SERVICE_NOMINATIM = 100;
	public static int POI_SERVICE_GEONAMES_WIKIPEDIA = 200;
	public static int POI_SERVICE_FLICKR = 300;
	public static int POI_SERVICE_PICASA = 400;
	public static int POI_SERVICE_4SQUARE = 500;

	/** Identifies the service provider of this POI. */
	public int serviceId;
	/** Nominatim: OSM ID. GeoNames: 0 */
	public String id;
	/** location of the POI */
	public GeoPoint location;
	public BoundingBox bbox;
	/** Nominatim "class", GeoNames "feature" */
	public String category;
	/** type or title */
	public String type;
	/** can be the name, the address, a short description */
	public String description;
	/** url of the thumbnail. Null if none */
	public String thumbnailPath;
	/** the thumbnail itself. Null if none */
	public Bitmap thumbnail;
	/** url to a more detailed information page about this POI. Null if none */
	public String url;
	/**
	 * popularity of this POI, from 1 (lowest) to 100 (highest). 0 if not
	 * defined.
	 */
	public int rank;

	/** number of attempts to load the thumbnail that have failed */
	protected int mThumbnailLoadingFailures;

	public POI(int serviceId) {
		this.serviceId = serviceId;
		// lets all other fields empty or null. That's fine.
	}

	protected static int MAX_LOADING_ATTEMPTS = 2;

	/**
	 * @return the POI thumbnail as a Bitmap, if any. If not done yet, it will
	 *         load the POI thumbnail from its url (in thumbnailPath field).
	 */
	public Bitmap getThumbnail() {
		if (thumbnail == null && thumbnailPath != null) {
// Path: src/org/osmdroid/utils/BonusPackHelper.java
// public class BonusPackHelper {
// 
// 	/** Log tag. */
// 	public static final String LOG_TAG = "BONUSPACK";
// 
// 	/** User agent sent to services by default */
// 	public static final String DEFAULT_USER_AGENT = "OsmBonusPack/1";
// 
// 	/**
// 	 * @return true if the device is the emulator, false if actual device.
// 	 */
// 	public static boolean isEmulator() {
// 		//return Build.MANUFACTURER.equals("unknown");
// 		return ("google_sdk".equals(Build.PRODUCT) || "sdk".equals(Build.PRODUCT));
// 	}
// 
// 	/**
// 	 * @param connection
// 	 *            ...
// 	 * @return the whole content of the http request, as a string
// 	 */
// 	private static String readStream(HttpConnection connection) {
// 		String result = connection.getContentAsString();
// 		return result;
// 	}
// 
// 	/**
// 	 * sends an http request, and returns the whole content result in a String.
// 	 * 
// 	 * @param url
// 	 *            ...
// 	 * @return the whole content, or null if any issue.
// 	 */
// 	public static String requestStringFromUrl(String url) {
// 		HttpConnection connection = new HttpConnection();
// 		connection.doGet(url);
// 		String result = readStream(connection);
// 		connection.close();
// 		return result;
// 	}
// 
// 	/**
// 	 * requestStringFromPost: do a post request to a url with name-value pairs,
// 	 * and returns the whole content result in a String.
// 	 * 
// 	 * @param url
// 	 *            ...
// 	 * @param nameValuePairs
// 	 *            ...
// 	 * @return the content, or null if any issue.
// 	 */
// 	public static String requestStringFromPost(String url, List<NameValuePair> nameValuePairs) {
// 		HttpConnection connection = new HttpConnection();
// 		connection.doPost(url, nameValuePairs);
// 		String result = readStream(connection);
// 		connection.close();
// 		return result;
// 	}
// 
// 	/**
// 	 * Loads a bitmap from a url.
// 	 * 
// 	 * @param url
// 	 *            ...
// 	 * @return the bitmap, or null if any issue.
// 	 */
// 	public static Bitmap loadBitmap(String url) {
// 		Bitmap bitmap = null;
// 		try {
// 			InputStream is = (InputStream) new URL(url).getContent();
// 			bitmap = BitmapFactory.decodeStream(new FlushedInputStream(is));
// 			//Alternative providing better handling on loading errors?
// 			/* Drawable d = Drawable.createFromStream(new
// 			 * FlushedInputStream(is), null); if (is != null) is.close(); if (d
// 			 * != null) bitmap = ((BitmapDrawable)d).getBitmap(); */
// 		} catch (FileNotFoundException e) {
// 			//log.debug("image not available: " + url);
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 			return null;
// 		}
// 		return bitmap;
// 	}
// 
// 	/**
// 	 * Workaround on Android issue see
// 	 * http://stackoverflow.com/questions/4601352
// 	 * /createfromstream-in-android-returning-null-for-certain-url
// 	 */
// 	static class FlushedInputStream extends FilterInputStream {
// 		public FlushedInputStream(InputStream inputStream) {
// 			super(inputStream);
// 		}
// 
// 		@Override
// 		public long skip(long n) throws IOException {
// 			long totalBytesSkipped = 0L;
// 			while (totalBytesSkipped < n) {
// 				long bytesSkipped = in.skip(n - totalBytesSkipped);
// 				if (bytesSkipped == 0L) {
// 					int byteValue = read();
// 					if (byteValue < 0)
// 						break; // we reached EOF
// 
// 					bytesSkipped = 1; // we read one byte
// 				}
// 				totalBytesSkipped += bytesSkipped;
// 			}
// 			return totalBytesSkipped;
// 		}
// 	}
// }


// Path: src/org/osmdroid/location/POI.java
import org.oscim.app.R;
import org.oscim.core.BoundingBox;
import org.oscim.core.GeoPoint;
import org.osmdroid.utils.BonusPackHelper;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.view.View;
import android.widget.ImageView;

package org.osmdroid.location;



/**
 * Point of Interest. Exact content may depend of the POI provider used.
 * 
 * @see NominatimPOIProvider
 * @see GeoNamesPOIProvider
 * @author M.Kergall
 */
public class POI {

	/** IDs of POI services */
	public static int POI_SERVICE_NOMINATIM = 100;
	public static int POI_SERVICE_GEONAMES_WIKIPEDIA = 200;
	public static int POI_SERVICE_FLICKR = 300;
	public static int POI_SERVICE_PICASA = 400;
	public static int POI_SERVICE_4SQUARE = 500;

	/** Identifies the service provider of this POI. */
	public int serviceId;
	/** Nominatim: OSM ID. GeoNames: 0 */
	public String id;
	/** location of the POI */
	public GeoPoint location;
	public BoundingBox bbox;
	/** Nominatim "class", GeoNames "feature" */
	public String category;
	/** type or title */
	public String type;
	/** can be the name, the address, a short description */
	public String description;
	/** url of the thumbnail. Null if none */
	public String thumbnailPath;
	/** the thumbnail itself. Null if none */
	public Bitmap thumbnail;
	/** url to a more detailed information page about this POI. Null if none */
	public String url;
	/**
	 * popularity of this POI, from 1 (lowest) to 100 (highest). 0 if not
	 * defined.
	 */
	public int rank;

	/** number of attempts to load the thumbnail that have failed */
	protected int mThumbnailLoadingFailures;

	public POI(int serviceId) {
		this.serviceId = serviceId;
		// lets all other fields empty or null. That's fine.
	}

	protected static int MAX_LOADING_ATTEMPTS = 2;

	/**
	 * @return the POI thumbnail as a Bitmap, if any. If not done yet, it will
	 *         load the POI thumbnail from its url (in thumbnailPath field).
	 */
	public Bitmap getThumbnail() {
		if (thumbnail == null && thumbnailPath != null) {
			thumbnail = BonusPackHelper.loadBitmap(thumbnailPath);