use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.
the class ImagePipelineUtilsImpl method createDecodedImageRequestBuilder.
@Nullable
protected ImageRequestBuilder createDecodedImageRequestBuilder(@Nullable ImageRequestBuilder imageRequestBuilder, DecodedImageOptions imageOptions) {
if (imageRequestBuilder == null) {
return null;
}
ResizeOptions resizeOptions = imageOptions.getResizeOptions();
if (resizeOptions != null) {
imageRequestBuilder.setResizeOptions(resizeOptions);
}
RotationOptions rotationOptions = imageOptions.getRotationOptions();
if (rotationOptions != null) {
imageRequestBuilder.setRotationOptions(rotationOptions);
}
ImageDecodeOptions imageDecodeOptions = mImageDecodeOptionsProvider.create(imageRequestBuilder, imageOptions);
if (imageDecodeOptions != null) {
imageRequestBuilder.setImageDecodeOptions(imageDecodeOptions);
}
imageRequestBuilder.setLocalThumbnailPreviewsEnabled(imageOptions.areLocalThumbnailPreviewsEnabled());
Postprocessor postprocessor = imageOptions.getPostprocessor();
if (postprocessor != null) {
imageRequestBuilder.setPostprocessor(postprocessor);
}
if (imageOptions.isProgressiveDecodingEnabled() != null) {
imageRequestBuilder.setProgressiveRenderingEnabled(imageOptions.isProgressiveDecodingEnabled());
}
return imageRequestBuilder;
}
use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.
the class DraweeRecyclerViewFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
final RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
final int imageSize = (right - left) / SPAN_COUNT;
mResizeOptions = new ResizeOptions(imageSize, imageSize);
}
});
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), SPAN_COUNT);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
final SimpleAdapter adapter = new SimpleAdapter(new ArrayList<Uri>());
recyclerView.setAdapter(adapter);
final Spinner imageSource = view.findViewById(R.id.spinner_image_source);
ImageSourceSpinner.INSTANCE.setup(imageSource, sampleUris(), new Function1<List<Uri>, Unit>() {
@Override
public Unit invoke(List<Uri> uris) {
adapter.setData(uris);
return null;
}
});
}
use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.
the class FrescoHolder method onBind.
@Override
protected void onBind(String uriString) {
Uri uri = Uri.parse(uriString);
ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);
if (UriUtil.isNetworkUri(uri)) {
imageRequestBuilder.setProgressiveRenderingEnabled(true);
} else {
imageRequestBuilder.setResizeOptions(new ResizeOptions(mImageView.getLayoutParams().width, mImageView.getLayoutParams().height));
}
DraweeController draweeController = Fresco.newDraweeControllerBuilder().setImageRequest(imageRequestBuilder.build()).setOldController(mImageView.getController()).setControllerListener(mImageView.getListener()).setAutoPlayAnimations(true).build();
mImageView.setController(draweeController);
}
use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.
the class ImagePipelineUtilsImplTest method testBuildImageRequest_whenResizingEnabled_thenSetResizeOptions.
@Test
public void testBuildImageRequest_whenResizingEnabled_thenSetResizeOptions() {
ResizeOptions resizeOptions = ResizeOptions.forDimensions(123, 234);
final ImageOptions imageOptions = ImageOptions.create().resize(resizeOptions).build();
ImageRequest imageRequest = mImagePipelineUtils.buildImageRequest(URI, imageOptions);
assertThat(imageRequest).isNotNull();
assertThat(imageRequest.getSourceUri()).isEqualTo(URI);
assertThat(imageRequest.getResizeOptions()).isEqualTo(resizeOptions);
}
use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.
the class ResizeAndRotateProducerTest method testResizeRatio.
@Test
public void testResizeRatio() {
ResizeOptions resizeOptions = new ResizeOptions(512, 512);
assertEquals(0.5f, JpegTranscoderUtils.determineResizeRatio(resizeOptions, 1024, 1024), 0.01);
assertEquals(0.25f, JpegTranscoderUtils.determineResizeRatio(resizeOptions, 2048, 4096), 0.01);
assertEquals(0.5f, JpegTranscoderUtils.determineResizeRatio(resizeOptions, 4096, 512), 0.01);
}
Aggregations