Request.Method, Request.Priority
Modifier and Type | Field and Description |
---|---|
private static float |
IMAGE_BACKOFF_MULT
Default backoff multiplier for image requests
|
private static int |
IMAGE_MAX_RETRIES
Default number of retries for image requests
|
private static int |
IMAGE_TIMEOUT_MS
Socket timeout in milliseconds for image requests
|
private Config |
mDecodeConfig |
private Response.Listener<Bitmap> |
mListener |
private int |
mMaxHeight |
private int |
mMaxWidth |
private static java.lang.Object |
sDecodeLock
Decoding lock so that we don't decode more than one image at a time (to avoid OOM's)
|
Constructor and Description |
---|
ImageRequest(java.lang.String url,
Response.Listener<Bitmap> listener,
int maxWidth,
int maxHeight,
Config decodeConfig,
Response.ErrorListener errorListener)
Creates a new image request, decoding to a maximum specified width and
height.
|
Modifier and Type | Method and Description |
---|---|
protected void |
deliverResponse(Bitmap response)
Subclasses must implement this to perform delivery of the parsed
response to their listeners.
|
private Response<Bitmap> |
doParse(NetworkResponse response)
The real guts of parseNetworkResponse.
|
(package private) static int |
findBestSampleSize(int actualWidth,
int actualHeight,
int desiredWidth,
int desiredHeight)
Returns the largest power-of-two divisor for use in downscaling a bitmap
that will not result in the scaling past the desired dimensions.
|
Request.Priority |
getPriority()
Returns the
Request.Priority of this request; Request.Priority.NORMAL by default. |
private static int |
getResizedDimension(int maxPrimary,
int maxSecondary,
int actualPrimary,
int actualSecondary)
Scales one side of a rectangle to fit aspect ratio.
|
protected Response<Bitmap> |
parseNetworkResponse(NetworkResponse response)
Subclasses must implement this to parse the raw network response
and return an appropriate response type.
|
addMarker, cancel, compareTo, deliverError, getBody, getBodyContentType, getCacheEntry, getCacheKey, getHeaders, getMethod, getParams, getParamsEncoding, getPostBody, getPostBodyContentType, getPostParams, getPostParamsEncoding, getRetryPolicy, getSequence, getTag, getTimeoutMs, getTrafficStatsTag, getUrl, hasHadResponseDelivered, isCanceled, markDelivered, parseNetworkError, setCacheEntry, setRequestQueue, setRetryPolicy, setSequence, setShouldCache, setTag, shouldCache, toString
private static final int IMAGE_TIMEOUT_MS
private static final int IMAGE_MAX_RETRIES
private static final float IMAGE_BACKOFF_MULT
private final Response.Listener<Bitmap> mListener
private final Config mDecodeConfig
private final int mMaxWidth
private final int mMaxHeight
private static final java.lang.Object sDecodeLock
public ImageRequest(java.lang.String url, Response.Listener<Bitmap> listener, int maxWidth, int maxHeight, Config decodeConfig, Response.ErrorListener errorListener)
url
- URL of the imagelistener
- Listener to receive the decoded bitmapmaxWidth
- Maximum width to decode this bitmap to, or zero for nonemaxHeight
- Maximum height to decode this bitmap to, or zero for
nonedecodeConfig
- Format to decode the bitmap toerrorListener
- Error listener, or null to ignore errorspublic Request.Priority getPriority()
Request
Request.Priority
of this request; Request.Priority.NORMAL
by default.getPriority
in class Request<Bitmap>
private static int getResizedDimension(int maxPrimary, int maxSecondary, int actualPrimary, int actualSecondary)
maxPrimary
- Maximum size of the primary dimension (i.e. width for
max width), or zero to maintain aspect ratio with secondary
dimensionmaxSecondary
- Maximum size of the secondary dimension, or zero to
maintain aspect ratio with primary dimensionactualPrimary
- Actual size of the primary dimensionactualSecondary
- Actual size of the secondary dimensionprotected Response<Bitmap> parseNetworkResponse(NetworkResponse response)
Request
parseNetworkResponse
in class Request<Bitmap>
response
- Response from the networkprivate Response<Bitmap> doParse(NetworkResponse response)
protected void deliverResponse(Bitmap response)
Request
deliverResponse
in class Request<Bitmap>
response
- The parsed response returned by
Request.parseNetworkResponse(NetworkResponse)
static int findBestSampleSize(int actualWidth, int actualHeight, int desiredWidth, int desiredHeight)
actualWidth
- Actual width of the bitmapactualHeight
- Actual height of the bitmapdesiredWidth
- Desired width of the bitmapdesiredHeight
- Desired height of the bitmap