ImageRequest extends Request<Bitmap> { static int findBestSampleSize(int actualWidth, int actualHeight, int desiredWidth, int desiredHeight) { double wr = (double) actualWidth / desiredWidth; double hr = (double) actualHeight / desiredHeight; double ratio = Math.min(wr, hr); float n = 1.0f; while ((n * 2) <= ratio) { n *= 2; } return (int) n; } ImageRequest(String url, Response.Listener<Bitmap> listener, int maxWidth, int maxHeight, ScaleType scaleType, Config decodeConfig, Response.ErrorListener errorListener); @Deprecated  ImageRequest(String url, Response.Listener<Bitmap> listener, int maxWidth, int maxHeight, Config decodeConfig, Response.ErrorListener errorListener); @Override Priority getPriority(); static final int DEFAULT_IMAGE_TIMEOUT_MS; static final int DEFAULT_IMAGE_MAX_RETRIES; static final float DEFAULT_IMAGE_BACKOFF_MULT; }
@Test public void findBestSampleSize() { assertEquals(1, ImageRequest.findBestSampleSize(100, 150, 100, 150)); assertEquals(2, ImageRequest.findBestSampleSize(280, 160, 140, 80)); assertEquals(1, ImageRequest.findBestSampleSize(1000, 800, 501, 401)); assertEquals(4, ImageRequest.findBestSampleSize(100, 200, 24, 50)); }