com.herroworld.imagegrabber
Class ImageGrabber

java.lang.Object
  extended by com.herroworld.imagegrabber.ImageWorker
      extended by com.herroworld.imagegrabber.ImageResizer
          extended by com.herroworld.imagegrabber.ImageGrabber

public class ImageGrabber
extends ImageResizer

A simple subclass of ImageResizer that fetches and resizes images fetched from a URL.


Constructor Summary
ImageGrabber(Context context, int imageSize)
          Initialize providing a single target image size (used for both width and height);
ImageGrabber(Context context, int imageWidth, int imageHeight)
          Initialize providing a target image width and height for the processing images.
 
Method Summary
 java.io.File downloadBitmap(Context context, java.lang.String urlString, boolean forceFetch)
          Download a bitmap from a URL, write it to a disk and return the File pointer.
 boolean isModified(long lastModified, java.net.HttpURLConnection urlConnection)
          Checking for a server status code 304 response to determine if the image has been modified since the last time the file was written
 void setHttpCacheDir(java.lang.String dirName)
          Setter for http cache directory, default is http.
 void setHttpCacheSize(int cacheSize)
          Setter for http cache size, default is 10MB.
 
Methods inherited from class com.herroworld.imagegrabber.ImageResizer
calculateInSampleSize, decodeSampledBitmapFromFile, decodeSampledBitmapFromResource, setImageSize, setImageSize
 
Methods inherited from class com.herroworld.imagegrabber.ImageWorker
cancelWork, getImageCache, loadImage, setAlwaysFetchFromServer, setExitTasksEarly, setFadeInTime, setImageCache, setImageFadeIn, setLoadingImage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageGrabber

public ImageGrabber(Context context,
                    int imageWidth,
                    int imageHeight)
Initialize providing a target image width and height for the processing images.

Parameters:
context -
imageWidth -
imageHeight -

ImageGrabber

public ImageGrabber(Context context,
                    int imageSize)
Initialize providing a single target image size (used for both width and height);

Parameters:
context -
imageSize -
Method Detail

setHttpCacheSize

public void setHttpCacheSize(int cacheSize)
Setter for http cache size, default is 10MB.

Parameters:
cacheSize - In bytes.

setHttpCacheDir

public void setHttpCacheDir(java.lang.String dirName)
Setter for http cache directory, default is http.

Parameters:
dirName -

downloadBitmap

public java.io.File downloadBitmap(Context context,
                                   java.lang.String urlString,
                                   boolean forceFetch)
Download a bitmap from a URL, write it to a disk and return the File pointer. This implementation uses a simple disk cache.

Parameters:
context - The context to use
urlString - The URL to fetch
forceFetch - Whether or not to force a network response even if the image is cached
Returns:
A File pointing to the fetched bitmap

isModified

public boolean isModified(long lastModified,
                          java.net.HttpURLConnection urlConnection)
                   throws java.io.IOException
Checking for a server status code 304 response to determine if the image has been modified since the last time the file was written

Parameters:
lastModified - File last modified time
urlConnection -
Returns:
If file on server has been modified
Throws:
java.io.IOException