use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method onlyScaleDownOriginalSmaller.
@Test
public void onlyScaleDownOriginalSmaller() {
Bitmap source = Bitmap.createBitmap(50, 50, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(100, 100).onlyScaleDown().build();
Bitmap result = transformResult(data, source, 0);
assertThat(result).isSameInstanceAs(source);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isNull();
assertThat(shadowBitmap.getCreatedFromBitmap()).isNotSameInstanceAs(source);
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method rotation90Sizing.
@Test
public void rotation90Sizing() {
Request data = new Request.Builder(URI_1).rotate(90).resize(5, 10).build();
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Bitmap result = transformResult(data, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameInstanceAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPreOperations()).contains("scale 1.0 0.5");
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class PicassoTest method resumeActionImmediatelyCompletesCachedRequest.
@Test
public void resumeActionImmediatelyCompletesCachedRequest() {
cache.set(URI_KEY_1, bitmap);
Request request = new Request.Builder(URI_1, 0, ARGB_8888).build();
Action action = new Action(mockPicasso(), request) {
@Override
public void complete(RequestHandler.Result result) {
assertThat(result).isInstanceOf(RequestHandler.Result.Bitmap.class);
RequestHandler.Result.Bitmap bitmapResult = (RequestHandler.Result.Bitmap) result;
assertThat(bitmapResult.getBitmap()).isEqualTo(bitmap);
assertThat(bitmapResult.loadedFrom).isEqualTo(MEMORY);
}
@Override
public void error(Exception e) {
fail("Reading from memory cache should not throw an exception");
}
@NonNull
@Override
public Object getTarget() {
return this;
}
};
picasso.resumeAction(action);
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class Picasso method complete.
void complete(BitmapHunter hunter) {
Action single = hunter.getAction();
List<Action> joined = hunter.getActions();
boolean hasMultiple = joined != null && !joined.isEmpty();
boolean shouldDeliver = single != null || hasMultiple;
if (!shouldDeliver) {
return;
}
Uri uri = checkNotNull(hunter.data.uri, "uri == null");
Exception exception = hunter.getException();
Result result = hunter.getResult();
if (single != null) {
deliverAction(result, single, exception);
}
if (joined != null) {
// noinspection ForLoopReplaceableByForEach
for (int i = 0, n = joined.size(); i < n; i++) {
Action join = joined.get(i);
deliverAction(result, join, exception);
}
}
if (listener != null && exception != null) {
listener.onImageLoadFailed(this, uri, exception);
}
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method exifTranspose.
@Test
public void exifTranspose() {
Request data = new Request.Builder(URI_1).rotate(-45).build();
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Bitmap result = transformResult(data, source, ORIENTATION_TRANSPOSE);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameInstanceAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPostOperations()).containsExactly("scale -1.0 1.0");
assertThat(shadowMatrix.getPreOperations()).containsExactly("rotate 90.0");
}
Aggregations