|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.herroworld.imagegrabber.ImageWorker
public abstract class ImageWorker
This class wraps up completing some arbitrary long running work when loading a bitmap to an ImageView. It handles things like using a memory and disk cache, running the work in a background thread and setting a placeholder image. It also allows forcing a network response to refresh the disk cache.
Method Summary | |
---|---|
static void |
cancelWork(ImageView imageView)
|
ImageCache |
getImageCache()
Get the ImageCache object for reuse. |
void |
loadImage(java.lang.Object data,
ImageView imageView)
Load an image specified by the data parameter into an ImageView (override ImageWorker#processBitmap(Object) to define the processing
logic). |
void |
setAlwaysFetchFromServer(boolean fetch)
If set to true, image will be returned from cache if available and simultaneously re-fetch the image from network if it has changed since the last time. |
void |
setExitTasksEarly(boolean exitTasksEarly)
If set to true, all intermediate tasks will be cancelled. |
void |
setFadeInTime(int fadeInTime)
Set the fade in time when bitmap is loaded into the image view. |
void |
setImageCache(ImageCache cacheCallback)
Set the ImageCache object to use with this ImageWorker. |
void |
setImageFadeIn(boolean fadeIn)
If set to true, the image will fade-in once it has been loaded by the background thread. |
void |
setLoadingImage(Bitmap bitmap)
Set placeholder bitmap that shows when the the background thread is running. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void setFadeInTime(int fadeInTime)
fadeInTime
- Fade in time in millisecondspublic void loadImage(java.lang.Object data, ImageView imageView)
ImageWorker#processBitmap(Object)
to define the processing
logic). A memory and disk cache will be used if an ImageCache
has
been set using setImageCache(ImageCache)
. If the
image is found in the memory cache, it is set immediately, otherwise an
AsyncTask
will be created to asynchronously load the bitmap.
data
- The URL of the image to download.imageView
- The ImageView to bind the downloaded image to.public void setLoadingImage(Bitmap bitmap)
bitmap
- public void setImageCache(ImageCache cacheCallback)
ImageCache
object to use with this ImageWorker.
cacheCallback
- public ImageCache getImageCache()
ImageCache
object for reuse.
ImageCache
objectpublic void setImageFadeIn(boolean fadeIn)
fadeIn
- public void setAlwaysFetchFromServer(boolean fetch)
fetch
- public void setExitTasksEarly(boolean exitTasksEarly)
exitTasksEarly
- public static void cancelWork(ImageView imageView)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |