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];
int bytesRead = 0;
int offset = 0;
while (bytesRead != -1 && offset < fileSize) {
bytesRead = istream.read(imageData, offset, fileSize - offset);
offset += bytesRead;
}
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.
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.