AndBase开发框架  1.6
 全部  命名空间 文件 函数 变量 枚举值 
| Public 成员函数 | Private 成员函数 | 静态 Private 成员函数 | Private 属性 | 所有成员列表
com.ab.image.toolbox.ImageLoader类 参考

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.

构造及析构函数说明

com.ab.image.toolbox.ImageLoader.ImageLoader ( RequestQueue  queue,
ImageCache  imageCache 
)
inline

Constructs a new ImageLoader.

参数
queueThe RequestQueue to use for making image requests.
imageCacheThe cache to use as an L1 cache.

成员函数说明

void com.ab.image.toolbox.ImageLoader.batchResponse ( String  cacheKey,
BatchedImageRequest  request 
)
inlineprivate

Starts the runnable for batched delivery of responses if it is not already started.

参数
cacheKeyThe cacheKey of the response being delivered.
requestThe BatchedImageRequest to be delivered.
errorThe volley error associated with the request (if applicable).
ImageContainer com.ab.image.toolbox.ImageLoader.get ( String  requestUrl,
final ImageListener  listener 
)
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.

参数
requestUrlThe URL of the image to be loaded.
defaultImageOptional default image to return until the actual image is loaded.
ImageContainer com.ab.image.toolbox.ImageLoader.get ( String  requestUrl,
ImageListener  imageListener,
int  maxWidth,
int  maxHeight 
)
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).

参数
requestUrlThe url of the remote image
imageListenerThe listener to call when the remote image is loaded
maxWidthThe maximum width of the returned image.
maxHeightThe maximum height of the returned image.
返回
A container object that contains all of the properties of the request, as well as the currently available image (default if remote is not loaded).
static String com.ab.image.toolbox.ImageLoader.getCacheKey ( String  url,
int  maxWidth,
int  maxHeight 
)
inlinestaticprivate

Creates a cache key for use with the L1 cache.

参数
urlThe URL of the request.
maxWidthThe max-width of the output.
maxHeightThe max-height of the output.
boolean com.ab.image.toolbox.ImageLoader.isCached ( String  requestUrl,
int  maxWidth,
int  maxHeight 
)
inline

Checks if the item is available in the cache.

参数
requestUrlThe url of the remote image
maxWidthThe maximum width of the returned image.
maxHeightThe maximum height of the returned image.
返回
True if the item exists in cache, false otherwise.
void com.ab.image.toolbox.ImageLoader.onGetImageError ( String  cacheKey,
VolleyError  error 
)
inlineprivate

Handler for when an image failed to load.

参数
cacheKeyThe cache key that is associated with the image request.
void com.ab.image.toolbox.ImageLoader.onGetImageSuccess ( String  cacheKey,
Bitmap  response 
)
inlineprivate

Handler for when an image was successfully loaded.

参数
cacheKeyThe cache key that is associated with the image request.
responseThe bitmap that was returned from the network.
void com.ab.image.toolbox.ImageLoader.setBatchedResponseDelay ( int  newBatchedResponseDelayMs)
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.

参数
newBatchedResponseDelayMsThe time in milliseconds to wait.
void com.ab.image.toolbox.ImageLoader.throwIfNotOnMainThread ( )
inlineprivate

类成员变量说明

final HashMap<String, BatchedImageRequest> com.ab.image.toolbox.ImageLoader.mBatchedResponses
private
初始值:
=
new HashMap<String, BatchedImageRequest>()

HashMap of the currently pending responses (waiting to be delivered).

int com.ab.image.toolbox.ImageLoader.mBatchResponseDelayMs = 100
private

Amount of time to wait after first response arrives before delivering all responses.

final ImageCache com.ab.image.toolbox.ImageLoader.mCache
private

The cache implementation to be used as an L1 cache before calling into volley.

final Handler com.ab.image.toolbox.ImageLoader.mHandler = new Handler(Looper.getMainLooper())
private

Handler to the main thread.

final HashMap<String, BatchedImageRequest> com.ab.image.toolbox.ImageLoader.mInFlightRequests
private
初始值:
=
new HashMap<String, BatchedImageRequest>()

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.

final RequestQueue com.ab.image.toolbox.ImageLoader.mRequestQueue
private

RequestQueue for dispatching ImageRequests onto.

Runnable com.ab.image.toolbox.ImageLoader.mRunnable
private

Runnable for in-flight response delivery.


该类的文档由以下文件生成: