use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class Dispatcher method deliver.
private void deliver(BitmapHunter hunter) {
if (hunter.isCancelled()) {
return;
}
Result result = hunter.getResult();
if (result != null) {
if (result instanceof Result.Bitmap) {
Bitmap bitmap = ((Result.Bitmap) result).getBitmap();
bitmap.prepareToDraw();
}
}
Message message = mainThreadHandler.obtainMessage(HUNTER_COMPLETE, hunter);
if (hunter.priority == Picasso.Priority.HIGH) {
mainThreadHandler.sendMessageAtFrontOfQueue(message);
} else {
mainThreadHandler.sendMessage(message);
}
logDelivery(hunter);
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method centerInsideTallTooLarge.
@Test
public void centerInsideTallTooLarge() {
Bitmap source = Bitmap.createBitmap(100, 50, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(50, 50).centerInside().build();
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()).containsExactly("scale 0.5 0.5");
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method onlyScaleDownOriginalBigger.
@Test
public void onlyScaleDownOriginalBigger() {
Bitmap source = Bitmap.createBitmap(100, 100, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(50, 50).onlyScaleDown().build();
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()).containsExactly("scale 0.5 0.5");
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method exifHorizontalFlip.
@Test
public void exifHorizontalFlip() {
Request data = new Request.Builder(URI_1).rotate(-45).build();
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Bitmap result = transformResult(data, source, ORIENTATION_FLIP_HORIZONTAL);
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()).doesNotContain("rotate 180.0");
assertThat(shadowMatrix.getPreOperations()).doesNotContain("rotate 90.0");
assertThat(shadowMatrix.getPreOperations()).doesNotContain("rotate 270.0");
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method centerInsideResultMatchesTargetSizeWhileDesiredWidthIs0.
@Test
public void centerInsideResultMatchesTargetSizeWhileDesiredWidthIs0() {
Request request = new Request.Builder(URI_1).resize(0, 642).centerInside().build();
Bitmap source = Bitmap.createBitmap(640, 640, ARGB_8888);
Bitmap result = transformResult(request, source, 0);
assertThat(result.getWidth()).isEqualTo(642);
assertThat(result.getHeight()).isEqualTo(642);
}
Aggregations