Reputation: 4063
I have trouble finding the right workflow to load images into cache.
What I want to do:
I have all the data loaded from rest and stored in a DB, but I'm new to caching images.
What I go so far: - Inserted Universal Image Loader into my project (https://github.com/nostra13/Android-Universal-Image-Loader) - I tried
imageLoader.loadImage(url of an image, new SimpleImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
super.onLoadingStarted(imageUri, view);
//notify me the image started loading
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
//notify me the image is loaded
}
}
But when I check:
int size = MemoryCacheUtils.findCachedBitmapsForImageUri(url from that image, ImageLoader.getInstance().getMemoryCache()).size();
//show me the size
it's always zero.
My question is the following: am I going in the right direction or do I need to fix this someother way?
Upvotes: 0
Views: 444
Reputation: 4063
I found a better solution: ShutterBug (Android alternative for SDWebImage for iOs). It's easy to add urls to the ShutterbugManager and when I want to fill an ImageView (FetchableImageView in Shutterbug) with an image, it grabs the image from cache.
Upvotes: 1