类 | |
| class | BatchedImageRequest |
| interface | ImageCache |
| class | ImageContainer |
| interface | ImageListener |
Public 成员函数 | |
| ImageLoader (RequestQueue queue, ImageCache imageCache) | |
| boolean | isCached (String requestUrl, int maxWidth, int maxHeight) |
| ImageContainer | get (String requestUrl, final ImageListener listener) |
| ImageContainer | get (String requestUrl, ImageListener imageListener, int maxWidth, int maxHeight) |
| void | setBatchedResponseDelay (int newBatchedResponseDelayMs) |
Private 成员函数 | |
| void | onGetImageSuccess (String cacheKey, Bitmap response) |
| void | onGetImageError (String cacheKey, VolleyError error) |
| void | batchResponse (String cacheKey, BatchedImageRequest request) |
| void | throwIfNotOnMainThread () |
静态 Private 成员函数 | |
| static String | getCacheKey (String url, int maxWidth, int maxHeight) |
Private 属性 | |
| final RequestQueue | mRequestQueue |
| int | mBatchResponseDelayMs = 100 |
| final ImageCache | mCache |
| final HashMap< String, BatchedImageRequest > | mInFlightRequests |
| final HashMap< String, BatchedImageRequest > | mBatchedResponses |
| final Handler | mHandler = new Handler(Looper.getMainLooper()) |
| Runnable | mRunnable |
Helper that handles loading and caching images from remote URLs.
The simple way to use this class is to call ImageLoader#get(String, ImageListener) and to pass in the default image listener provided by ImageLoader#getImageListener(ImageView, int, int). Note that all function calls to this class must be made from the main thead, and all responses will be delivered to the main thread as well.
|
inline |
Constructs a new ImageLoader.
| queue | The RequestQueue to use for making image requests. |
| imageCache | The cache to use as an L1 cache. |
|
inlineprivate |
Starts the runnable for batched delivery of responses if it is not already started.
| cacheKey | The cacheKey of the response being delivered. |
| request | The BatchedImageRequest to be delivered. |
| error | The volley error associated with the request (if applicable). |
|
inline |
Returns an ImageContainer for the requested URL.
The ImageContainer will contain either the specified default bitmap or the loaded bitmap. If the default was returned, the ImageLoader will be invoked when the request is fulfilled.
| requestUrl | The URL of the image to be loaded. |
| defaultImage | Optional default image to return until the actual image is loaded. |
|
inline |
Issues a bitmap request with the given URL if that image is not available in the cache, and returns a bitmap container that contains all of the data relating to the request (as well as the default image if the requested image is not available).
| requestUrl | The url of the remote image |
| imageListener | The listener to call when the remote image is loaded |
| maxWidth | The maximum width of the returned image. |
| maxHeight | The maximum height of the returned image. |
|
inlinestaticprivate |
Creates a cache key for use with the L1 cache.
| url | The URL of the request. |
| maxWidth | The max-width of the output. |
| maxHeight | The max-height of the output. |
|
inline |
Checks if the item is available in the cache.
| requestUrl | The url of the remote image |
| maxWidth | The maximum width of the returned image. |
| maxHeight | The maximum height of the returned image. |
|
inlineprivate |
Handler for when an image failed to load.
| cacheKey | The cache key that is associated with the image request. |
|
inlineprivate |
Handler for when an image was successfully loaded.
| cacheKey | The cache key that is associated with the image request. |
| response | The bitmap that was returned from the network. |
|
inline |
Sets the amount of time to wait after the first response arrives before delivering all responses. Batching can be disabled entirely by passing in 0.
| newBatchedResponseDelayMs | The time in milliseconds to wait. |
|
inlineprivate |
|
private |
HashMap of the currently pending responses (waiting to be delivered).
|
private |
Amount of time to wait after first response arrives before delivering all responses.
|
private |
The cache implementation to be used as an L1 cache before calling into volley.
|
private |
Handler to the main thread.
|
private |
HashMap of Cache keys -> BatchedImageRequest used to track in-flight requests so that we can coalesce multiple requests to the same URL into a single network request.
|
private |
RequestQueue for dispatching ImageRequests onto.
|
private |
Runnable for in-flight response delivery.
1.8.8