Android Image fetching library - android

Hi i wanted to know is their any library in which we pass the URL and the image-view and it checks whether the images is present on device if not, then fetch image from URL and store to device and bind with the view passed. I tried writing the code but once the view is loaded and image is not fetched the images is never fetched in future unless i uninstall the app , i also tried universal image loader library and asynchronous image loader

Picasso is doing all things what you want.
It loads from internet and cache
It loads from cache
It loads from Local File
Read More Here And Here

Try volley library. you have a NetworkImageView I guess. Which fits your need.

Related

Fetch Image from server by using url with Universal Image Loader

I am successfully fetching and caching image from server url by using Universal Image Loader. My DisplayImageOptions are given below.
new DisplayImageOptions.Builder().cacheInMemory(true)
.showImageOnLoading(R.drawable.home_back_img)
.showImageOnFail(R.drawable.home_back_img)
.bitmapConfig(Bitmap.Config.ALPHA_8)
.showImageForEmptyUri(R.drawable.home_back_img)
.build();
My problem is, when I updates image in server(with same file name), the image is not updated in application, its just using the cached file itself. Is there is any solution for this? Yes we can avoid caching, but then it might take some time to load the image every time, rather than avoid caching it would be nice if any solution exists. Help will be appreciated!
You must use different name to get the updated photo. Because , the image already stored in your local cache by the same name. So, It will never call to network to download the image .
Or , Clear your application cache , then you will get the updated image.

Using Glide for Android, what's a good way to use (local) alternative sources for urls?

I'm using Glide to load images in my Android app:
Glide.with(context)
.load("http://www.example.com/whatever/icon.png")
.into(imageView);
I would like to bundle some images in my app APK file to make sure that they are always available even if the device is offline. I would still like to use Glide to benefit from features such as memory caching of resized images, loading and scaling in a background thread and also to keep the interface for displaying images consistent.
Each image that I need to load like this is specified by a URL.
If there's a local version ( the local file name is generated by using a part of the URL [ e.g. replacing "http://www.example.com/" with "file:///android_asset/bundled_images/whatever/" ] in the URL string ), I would like to use that one. If not, the image needs to be downloaded from the actual URL.
Here's an example:
I have an image at http://www.example.com/whatever/icon.png
I will bundle this image in the apk under:
/assets/bundled_images/whatever/icon.png
The rule would be as follows:
If the image file exists under local assets, use that file. If the image does not exist under local assets, use the remote file.
Whenever I request an image to be loaded into an imageview, I would like to be able to use just the full URL (http://www.example.com/whatever/icon.png), and my image loader should automatically be able to check for a local copy first.
Can I do something like this with any of Glide's functionality? Yes, I could of course to the file exists check before calling glide, but it seems like a common enough use case that Glide could/should have a feature for this. Would also be nice to do the file-exists check in the background.
You can achieve required flexibility by adding custom GlideModule in the way described here: Glide Configuration. Also you need to implement appropriate Glide's Loader which would encapsulate the logic for downloading. In your case it can be something similar to UriLoader.
Glide provides an option to load a local image if the device is offline.
This can be done using the error() method.
Glide.with(this).load(imageUrl)
.error(localImageResId)
.into(mIconView);
The code above downloads an image from imageUrl and loads it into the imageView.
In case of an error (ex device offline) it loads the local image resourse.

With felipecsl Android-ImageManager library how can I replace a cached image

I am using felipecsl Android-ImageManager library to download some images from one of our servers and load it in a list view. In my Android application I have a feature to change that downloaded image from app side and upload it to server.
I do know how to load the image from URL because it is well documented with the above mentioned link. What I need is to change/delete a particular cached item and replace it with my new image from Android application side.
Let me explain it further. Normally what happens is, it loads an image from the provided URL and caches it in the manager's LRU and Disk cache. Then the second time call to that same URL, if the image is already cached, fetches it from the cache even I have set a different image from my application side.
Therefore how can I either delete that URL from cache OR set the new image for the cache of that same URL.
I have tried something like below, but seems it is not working.
imageManager.getCacheManager().getMemoryCache().put(ImageManager.getCacheKeyForJob(myUrl, jobOptions), bitmap);
That is not really supported by the library. If you need to do this kind of more advanced cache management, you can use Picasso (https://github.com/square/picasso), where you can set your own cache manager and have more control over your cached images.

Universal Image Loader reuse images in android

Using Universal Image Loader, is it possible to directly save images to disk and reuse those images between different runs of the application?
I know imageLoader.displayImage(imageURI, itemHolder.image, options); gets images from the cache the second time, but if you exit the app the cache is removed.
I want the display image method to save the image to a permanent location and use that location every time the app calls that method.
Is this possible using Universal Image Loader or do I need to find another way?
you need to download images to certain folder at first start up and after that you can load images using same method and you need to pass file location instead of url like:
imageLoader.displayImage("file:///sdcard/test.png", itemHolder.image, options);
Hope this will help you

Universal image loader recache from Internet

I use the Android Universal image loader,
and I set cacheInMemory and cacheOnDisc values to true.
Therefore, the imageloader downloads the images from the Internet,
and there images will be cached in order to load much more fast at the next time.
My question is that if these URLs of images are same but its contents are changed,
how the imageloader determine and resolve that situation and refresh these images of caches?
By default UIL doesn't check if image was changed on server. If image was cached on disk it will be used until it's deleted. So there are LimitedAgeMemoryCache and LimitedAgeDiscCache are exists for this case. They delete cached images after some time amount so updated images are loaded from server.

Categories

Resources