
com.qozix.tileview.graphics.BitmapDecoderHttp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TileView Show documentation
Show all versions of TileView Show documentation
The TileView widget is a subclass of ViewGroup that provides a mechanism to asynchronously display tile-based images, with additional functionality for 2D dragging, flinging, pinch or double-tap to zoom, adding overlaying Views (markers), built-in Hot Spot support, dynamic path drawing, multiple levels of detail, and support for any relative positioning or coordinate system.
The newest version!
package com.qozix.tileview.graphics;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import com.qozix.tileview.graphics.BitmapDecoder;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class BitmapDecoderHttp implements BitmapDecoder {
private static final BitmapFactory.Options OPTIONS = new BitmapFactory.Options();
static {
OPTIONS.inPreferredConfig = Bitmap.Config.RGB_565;
}
@Override
public Bitmap decode( String fileName, Context context ) {
try {
URL url = new URL(fileName);
try {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream input = connection.getInputStream();
if ( input != null ) {
try {
return BitmapFactory.decodeStream( input, null, OPTIONS );
} catch ( OutOfMemoryError oom ) {
// oom - you can try sleeping (this method won't be called in the UI thread) or try again (or give up)
} catch ( Exception e ) {
// unknown error decoding bitmap
}
}
} catch ( IOException e ) {
// io error
}
} catch ( MalformedURLException e1 ) {
// bad url
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy