Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Android image manager library
Java
branch: master

This branch is 14 commits ahead, 6 commits behind zonghai-li:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
res
src
.classpath
.gitignore
.project
AndroidManifest.xml
README.md
proguard.cfg
project.properties

README.md

This is a simple library that can address most of the requirement of asynchronously dowloading, caching and managing network resource (images). It was originally forked from here, then modified to fix bugs and add more features.

Loading an image is straightforward:

HttpImageManager.loadImage(new HttpImageManager.LoadRequest(uri, imageView));

Interface

To load an image, one will have to instantiate an HttpImageManager object, then

  • Set a target ImageView for displaying the loaded image HttpImageManager.loadImage(new HttpImageManager.LoadRequest(uri, imageView));

  • Or set a listener for being notified of the result

        HttpImageManager.loadImage(new HttpImageManager.LoadRequest(uri, new HttpImageManager.OnLoadResponseListener() {
    
                    @Override
                    public void onLoadResponse(LoadRequest r, Bitmap data) {
                    }
    
                    @Override
                    public void onLoadError(LoadRequest r, Throwable e) {
                    }
    
                    @Override
                    public void onLoadProgress(LoadRequest r, long totalContentSize,
                                long loadedContentSize) {
                    }
        }));
    

Three-Level Caching Hierarchy

[memory cache] -> [persistent storage cache] -> [network loader]

The memory cache is optional. To use too much memory cache may kill the system resource very fast. It is important to do so with a list view, though.

LIFO Thread Pool

We use a LIFO queue for threading pool. This is to improve responsiveness of a listview, for example, when a user scrolls down the list that loads a quite number of images sequentially.

Write-back Protection for List Adapters

When used in list adapters that utilize techniques of reusing inflated view objects, the same ImageView object might be set as targets in a row of requests for difference resources. Since HttpImageManager works asynchronously, the previously requested resource may come late and gets written back to the wrong ImageView object. To prevent this write-back, we always bind the requested URL to the ImageView object. After the resource being downloaded, a comparison will be performed to check if the ImageView object is still representing the requested URL. This binding is realized by setting the ImageView's tag object. So, caller can not use the setTag() for other purpose during the process of HttpImageManager.

More features

  • Loading progress listener for large full-sized pictures
  • Post manipulation of the loaded image by plugging in BitmapFilter
  • Synchronous call wrapper

New features

  • Image transition effect
  • Better Memory Usage
  • Faster image loading
  • Pausable/Resumable ThreadPool (for smooth list scrolling)
  • Option to keep alpha layer
  • Create thumbnail on the fly
Something went wrong with that request. Please try again.