Back to project page Android-Lib-AsyncImageLoader.
The source code is released under:
Apache License
If you think the Android project Android-Lib-AsyncImageLoader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package android.lib.asyncimageloader; /*from w w w.jav a 2 s . co m*/ import java.net.URL; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.widget.AbsListView; import android.widget.BaseAdapter; import android.widget.ImageView; public abstract class GalleryAdapter extends BaseAdapter { /** * A base class for holding the {@link ImageView} of the view used by the items in a {@link AbsListView}. */ public class GalleryViewHolder { /** * The {@link ImageView} of the view used by the items in a {@link AbsListView}. */ public final ImageView imageView; /** * Creates a new instance of {@link GalleryViewHolder}. * @param imageView the {@link ImageView} of the view used by the items in a {@link AbsListView}. */ public GalleryViewHolder(final ImageView imageView) { this.imageView = imageView; } } protected final AsyncImageLoader imageLoader; /** * Creates a new instance of {@link GalleryAdapter}. * @param activity the activity that hosts the {@link ImageView}s used by the items in a {@link AbsListView}. * @param numberOfCachedBitmaps the maximum number of {@link Bitmap} objects cached in memory. * @param thumbnailPath the path to store any generated thumbnails. */ public GalleryAdapter(final Activity activity, final int numberOfCachedBitmaps, final String thumbnailPath) { this.imageLoader = new AsyncImageLoader(activity, numberOfCachedBitmaps, thumbnailPath); } /** * Cleans up any resources used by the adapter. * <p>Note: This method must be called in {@link Activity#onDestroy()}.</p> */ public final void onDestroy() { this.imageLoader.close(); } /** * Loads and displays a {@link Bitmap} at the given <code>path</code> for the {@link ImageView}. * @param path the path to load a {@link Bitmap}. * @param imageView the {@link ImageView} to display the loaded {@link Bitmap}. */ protected void loadImage(final String path, final ImageView imageView) { this.imageLoader.loadImage(path, imageView); } /** * Loads and displays a {@link Bitmap} from the given <coed>url</code> for the {@link ImageView}. * @param url the URL to get the bitmap data from. * @param imageView the {@link ImageView} to display the loaded {@link Bitmap}. */ protected void loadImage(final URL url, final ImageView imageView) { this.imageLoader.loadImage(url, imageView); } /** * Loads and displays a {@link Bitmap} at the given <code>path</code> for the {@link ImageView}. * @param path the path to load a {@link Bitmap}. * @param imageView the {@link ImageView} to display the loaded {@link Bitmap}. * @param options the bitmap options, if any, used for loading the {@link Bitmap}. */ protected void loadImage(final String path, final ImageView imageView, final BitmapFactory.Options options) { this.imageLoader.loadImage(path, imageView, options); } /** * Loads and displays a {@link Bitmap} at the given <code>path</code> for the {@link ImageView}. * @param path the path to load a {@link Bitmap}. * @param imageView the {@link ImageView} to display the loaded {@link Bitmap}. * @param listener a callback when the loading process completes. */ protected void loadImage(final String path, final ImageView imageView, final OnImageLoadedListener listener) { this.imageLoader.loadImage(path, imageView, listener); } /** * Loads and displays a {@link Bitmap} from the given <coed>url</code> for the {@link ImageView}. * @param url the URL to get the bitmap data from. * @param imageView the {@link ImageView} to display the loaded {@link Bitmap}. * @param listener a callback when the loading process completes. */ protected void loadImage(final URL url, final ImageView imageView, final OnImageLoadedListener listener) { this.imageLoader.loadImage(url, imageView, listener); } /** * Loads and displays a {@link Bitmap} at the given <code>path</code> for the {@link ImageView}. * @param path the path to load a {@link Bitmap}. * @param imageView the {@link ImageView} to display the loaded {@link Bitmap}. * @param options the bitmap options, if any, used for loading the {@link Bitmap}. * @param listener a callback when the loading process completes. */ protected void loadImage(final String path, final ImageView imageView, final BitmapFactory.Options options, final OnImageLoadedListener listener) { this.imageLoader.loadImage(path, imageView, options, listener); } /** * Loads and displays a {@link Bitmap} thumbnail of the image at the given <code>path</code> for the {@link ImageView}. * @param path the path to load a {@link Bitmap}. * @param imageView the {@link ImageView} to display the loaded {@link Bitmap}. * @param kind either {@link android.provider.MediaStore.Images.Thumbnails#MINI_KIND} or * {@link android.provider.MediaStore.Images.Thumbnails#MICRO_KIND}, or -1 if this parameter is irrelevant. */ protected void loadImageThumbnail(final String path, final ImageView imageView, final int kind) { this.imageLoader.loadImageThumbnail(path, imageView, kind); } /** * Loads and displays a {@link Bitmap} thumbnail of the image at the given <code>path</code> for the {@link ImageView}. * @param path the path to load a {@link Bitmap}. * @param imageView the {@link ImageView} to display the loaded {@link Bitmap}. * @param kind either {@link android.provider.MediaStore.Images.Thumbnails#MINI_KIND} or * {@link android.provider.MediaStore.Images.Thumbnails#MICRO_KIND}, or -1 if this parameter is irrelevant. * @param listener a callback when the loading process completes. */ protected void loadImageThumbnail(final String path, final ImageView imageView, final int kind, final OnImageLoadedListener listener) { this.imageLoader.loadImageThumbnail(path, imageView, kind, listener); } /** * Loads and displays a {@link Bitmap} thumbnail of the video at the given <code>path</code> for the {@link ImageView}. * @param path the path to load a {@link Bitmap}. * @param imageView the {@link ImageView} to display the loaded {@link Bitmap}. * @param kind either {@link android.provider.MediaStore.Video.Thumbnails#MINI_KIND} or * {@link android.provider.MediaStore.Video.Thumbnails#MICRO_KIND}, or -1 if this parameter is irrelevant. */ protected void loadVideoThumbnail(final String path, final ImageView imageView, final int kind) { this.imageLoader.loadVideoThumbnail(path, imageView, kind); } /** * Loads and displays a {@link Bitmap} thumbnail of the video at the given <code>path</code> for the {@link ImageView}. * @param path the path to load a {@link Bitmap}. * @param imageView the {@link ImageView} to display the loaded {@link Bitmap}. * @param kind either {@link android.provider.MediaStore.Video.Thumbnails#MINI_KIND} or * {@link android.provider.MediaStore.Video.Thumbnails#MICRO_KIND}, or -1 if this parameter is irrelevant. * @param listener a callback when the loading process completes. */ protected void loadVideoThumbnail(final String path, final ImageView imageView, final int kind, final OnImageLoadedListener listener) { this.imageLoader.loadVideoThumbnail(path, imageView, kind, listener); } }