lexs / webimageloader Goto Github PK
View Code? Open in Web Editor NEWLibrary to handle asynchronous image loading on Android.
License: Apache License 2.0
Library to handle asynchronous image loading on Android.
License: Apache License 2.0
Images that are being redirected fail to load.
Example:
Loading the URL http://api.twitter.com/1/users/profile_image?screen_name=bdesmet_&size=bigger fails with the following error message:
09-18 20:37:20.653: D/skia(16308): --- SkImageDecoder::Factory returned null
09-18 20:37:20.669: D/ImageHelper(16308): Error loading bitmap
09-18 20:37:20.669: D/ImageHelper(16308): java.io.IOException: Failed to create bitmap, decodeStream() returned null
09-18 20:37:20.669: D/ImageHelper(16308): at com.webimageloader.util.BitmapUtils.decodeStream(BitmapUtils.java:42)
09-18 20:37:20.669: D/ImageHelper(16308): at com.webimageloader.loader.PendingRequests$RequestListener.onStreamLoaded(PendingRequests.java:144)
09-18 20:37:20.669: D/ImageHelper(16308): at com.webimageloader.loader.NetworkLoader.loadInBackground(NetworkLoader.java:94)
09-18 20:37:20.669: D/ImageHelper(16308): at com.webimageloader.loader.BackgroundLoader$1.run(BackgroundLoader.java:22)
09-18 20:37:20.669: D/ImageHelper(16308): at com.webimageloader.concurrent.ListenerFuture.run(ListenerFuture.java:21)
09-18 20:37:20.669: D/ImageHelper(16308): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
09-18 20:37:20.669: D/ImageHelper(16308): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-18 20:37:20.669: D/ImageHelper(16308): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-18 20:37:20.669: D/ImageHelper(16308): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
09-18 20:37:20.669: D/ImageHelper(16308): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
09-18 20:37:20.669: D/ImageHelper(16308): at java.lang.Thread.run(Thread.java:856)
09-18 20:37:20.669: D/ImageHelper(16308): at com.webimageloader.util.PriorityThreadFactory$1.run(PriorityThreadFactory.java:26)
If you load the URL to which the first URL redirects (https://si0.twimg.com/profile_images/1593219329/333834_10150325451617266_569922265_8295088_379754916_o_bigger.jpg) everything works fine.
Hi,
I think your api very cool. It solved all my problems to load images. Thank you very much for your contribuition.
But, I still need two little things to can use this API in my App. First, I need to verify the user permission to see the image. So my webservice is prepared to receive a XML post with the login details, to confirm permissions.
Something like this:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(requestURL);
StringEntity se = new StringEntity(requestXMLMessage, HTTP.ISO_8859_1);
se.setContentType(text/xml);
httppost.setEntity(se);
It is possible to add the usability on this custom request to load images?
Thank you very much,
Ricardo
Will you generate a new version using the new version of DiskLRU?
Thx
Hi,
First I must say it's the best image loading library for android that I've found so far. Thanks for this awesome work!
I've tried to use it in my project, I'm using transformation to make the image rounded. Everything works amazing, but when the disk cache is enabled and the image being loaded from the cache, it's being displayed with black background instead of transparent background in the area that was clipped (attached picture).
Is it a configuration that I'm missing or a bug? BTW, in which format the image being saved in the cache, because if it's the same format as the original image and it doesn't support transparency, it might be the root for the problem.
Would love to get some help with that!
Thanks,
Lior
I noticed that you reimplement HTTP caching (respecting etags and other headers) when Android 4.0 and later does this for you - see https://developer.android.com/reference/android/net/http/HttpResponseCache.html
To support versions of Android before 4.0, you could use my library: https://github.com/candrews/httpresponsecache
I only point this out as implementing these parts of the HTTP protocol aren't easy, and I haven't examined your code terribly closely, but I'd be willing to bet it isn't up to feature parity or have as few bugs as the Android implementation. You could probably save yourself a lot of maintenance headache by reusing a library for this.
Hi, I noticed there is an API ImageLoader#destroy(). After calling that, I found the Disk related thread got shutdown. So I wanna know if there are other ways I can do to clean up all the background threads (observed via DDMS) when current app returns back to the Launcher ?
Thanks a lot.
Sean
The error occurs when trying to use a custom ConnectionFactory for HTTPS
I downloaded the code and found the error.
On constructor of class NetworkLoader is missing the code below
this.connectionFactory = builder.connectionFactory
Just playing about with this under no network conditions and it seems that the last item to be fetched by the loader doesn't get committed to the disk cache.
Steps to reproduce:
(ddms says ImageLoader: Error loading bitmap)
Hi... if I try to import the code of the directory "webimagloader" in eclipse as a "excisting Code Android Project" i get errors because your package-declaration "com.webimageloader" does not fit your directory-structure "main.java.com.webimageloader". This is necessary for eclipse. I wonder if i'm doing something wrong or maybe dont know something. Why do you have this structure? Greets, Mate
If the URL have an %20, %2F or some other character like those, the image is not loaded.
Getting D/ImageHelper﹕ Error loading bitmap
A fix could be parse the URL to remove this characters.
To support e.g. https basic auth mechnism or addtional header attributes that are required to gain access to an image resource it should be possible to add custom header parameters to the request.
How about creating a duplicate of the load function which would retrieve the URI path to the downloaded/cached file (or null) instead of a Bitmap instance ?
This would be neat to integrate you library into an image gallery (imageviews inside view pager) without putting all the bitmaps in memory.
Some images are always re-loaded from the network.
Examle img url:
http://sga-book.ru/files/3383.04.01;Т-Т.01;2/images/image035.jpg
V/NetworkLoader﹕ Loaded http://sga-book.ru/files/3383.04.01;Т-Т.01;2/images/image035.jpg from network
....
Build ImageLoader in default param in ImageLoaderApplication.java
Is there any way to pause the async tasks? Reason I ask, is to pause the background threads while scrolling as there's too much work being done as the images scroll by for a listview with large number of images.
So, on scroll, I would pause the work and on scroll stop, I would resume the work.
Thanks,
Bhaskar
For some reason, when using the 1.1.6 version of webimageloader with 2.0.0 version of disklrucache, the project get noClassDefError exception
Hi,
Like I said on the previous message, thanks for your contribution. Your code is one of the bests for me.
And, I have only one more issue with this code. I need to set some flag on the API to ignore cache and force the image reload.
Because, I have a form that the user can change the image (profile picture), and after the new upload I call the the API to open the image, but it returns the obsolete cache picture.
Can you please help me on that?
Thanks,
Ricardo
Maybe you should have a look at this library: https://github.com/chrisbanes/Android-BitmapMemoryCache
It uses the LruCache, but also recycles the bitmap if it isn't displayed or cached.
The idea is to have an AsyncTask to call to allow downloading one or several files with progress updates.
Is there any way to bypass the cache explicitly and force the image to be downloaded?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.