-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image is blank after download is finished #29
Comments
Hi, I went through the original code and the solution which has been provided in #30. I have come up with this solution which I think will work for all the cases. Please go through the attached patch file and let me know if I this is correct or if it contains any mistakes. This is my first contribution to open source so please pardon me for any errors (I have tried my best to minimize those). patch file : https://gist.github.com/3084469 Thanks |
I found a bug in ignition-support library when using RemoteImageLoader to downloading images. Some images will not download correctly after finished downloading, especially on some mobile networks.
The root cause is in these lines in RemoteImageLoaderJob.java:
int fileSize = connection.getContentLength();
...
byte[] imageData = new byte[fileSize];
According to Android documentation of HttpURLConnection, "By default, this implementation of HttpURLConnection requests that servers use gzip compression. Since getContentLength() returns the number of bytes transmitted, you cannot use that method to predict how many bytes can be read from getInputStream().".
So when compression in use, getContentLength() will return bytes less than the total size of image data.
The text was updated successfully, but these errors were encountered: