diff options
author | Ficus Kirkpatrick <ficus@android.com> | 2013-06-10 17:01:29 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-06-10 17:01:29 +0000 |
commit | d843f88166f5a1a099cfc9ff35473b31b50b18af (patch) | |
tree | 393259df73ae4a6ad64260420f0d636ea63b6848 /src | |
parent | c3dea925af9b3523e2e01e8b7799e71ef558c1c5 (diff) | |
parent | dc5355251132a447e384e273127b1a8bdaf32f5a (diff) | |
download | volley-d843f88166f5a1a099cfc9ff35473b31b50b18af.tar.gz |
Merge "Fixed bug caused by batching responses in the ImageLoader"
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/volley/toolbox/ImageLoader.java | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/com/android/volley/toolbox/ImageLoader.java b/src/com/android/volley/toolbox/ImageLoader.java index 5735edd..c5f52a0 100755 --- a/src/com/android/volley/toolbox/ImageLoader.java +++ b/src/com/android/volley/toolbox/ImageLoader.java @@ -262,7 +262,7 @@ public class ImageLoader { request.mResponseBitmap = response; // Send the batched response - batchResponse(cacheKey, request, null); + batchResponse(cacheKey, request); } } @@ -275,9 +275,12 @@ public class ImageLoader { // Remove this request from the list of in-flight requests. BatchedImageRequest request = mInFlightRequests.remove(cacheKey); + // Set the error for this request + request.setError(error); + if (request != null) { // Send the batched response - batchResponse(cacheKey, request, error); + batchResponse(cacheKey, request); } } @@ -365,6 +368,9 @@ public class ImageLoader { /** The result of the request being tracked by this item */ private Bitmap mResponseBitmap; + /** Error if one occurred for this response */ + private VolleyError mError; + /** List of all of the active ImageContainers that are interested in the request */ private final LinkedList<ImageContainer> mContainers = new LinkedList<ImageContainer>(); @@ -379,6 +385,20 @@ public class ImageLoader { } /** + * Set the error for this response + */ + public void setError(VolleyError error) { + mError = error; + } + + /** + * Get the error for this response + */ + public VolleyError getError() { + return mError; + } + + /** * Adds another ImageContainer to the list of those interested in the results of * the request. */ @@ -408,8 +428,7 @@ public class ImageLoader { * @param request The BatchedImageRequest to be delivered. * @param error The volley error associated with the request (if applicable). */ - private void batchResponse(String cacheKey, BatchedImageRequest request, - final VolleyError error) { + private void batchResponse(String cacheKey, BatchedImageRequest request) { mBatchedResponses.put(cacheKey, request); // If we don't already have a batch delivery runnable in flight, make a new one. // Note that this will be used to deliver responses to all callers in mBatchedResponses. @@ -425,11 +444,11 @@ public class ImageLoader { if (container.mListener == null) { continue; } - if (error == null) { + if (bir.getError() == null) { container.mBitmap = bir.mResponseBitmap; container.mListener.onResponse(container, false); } else { - container.mListener.onErrorResponse(error); + container.mListener.onErrorResponse(bir.getError()); } } } |