Search in sources :

Example 1 with ImageDecodeOptionsBuilder

use of com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder in project fresco by facebook.

the class DraweeRotationFragment method setRotationOptions.

private void setRotationOptions(RotationOptions rotationOptions) {
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri).setRotationOptions(rotationOptions).setImageDecodeOptions(new ImageDecodeOptionsBuilder().build()).build();
    mSimpleDraweeView.setImageRequest(imageRequest);
}
Also used : ImageRequest(com.facebook.imagepipeline.request.ImageRequest) ImageDecodeOptionsBuilder(com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder)

Example 2 with ImageDecodeOptionsBuilder

use of com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder in project fresco by facebook.

the class ImageFormatGifFragment method setAnimationUri.

private void setAnimationUri(Uri uri) {
    final PipelineDraweeControllerBuilder controllerBuilder = Fresco.newDraweeControllerBuilder().setAutoPlayAnimations(mAutoPlayEnabled).setOldController(mSimpleDraweeView.getController());
    final ImageDecodeOptionsBuilder optionsBuilder = ImageDecodeOptions.newBuilder().setMaxDimensionPx(4000);
    if (mGifDecoder != null) {
        optionsBuilder.setCustomImageDecoder(mGifDecoder);
    }
    controllerBuilder.setImageRequest(ImageRequestBuilder.newBuilderWithSource(uri).setImageDecodeOptions(optionsBuilder.build()).build());
    if (!mAutoPlayEnabled) {
        controllerBuilder.setControllerListener(new BaseControllerListener<ImageInfo>() {

            @Override
            public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable final Animatable animatable) {
                if (animatable != null) {
                    mSimpleDraweeView.getHierarchy().setOverlayImage(getPlayOverlayDrawable());
                    mSimpleDraweeView.setOnClickListener(new View.OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            if (animatable.isRunning()) {
                                animatable.stop();
                                mSimpleDraweeView.getHierarchy().setOverlayImage(getPlayOverlayDrawable());
                            } else {
                                animatable.start();
                                mSimpleDraweeView.getHierarchy().setOverlayImage(null);
                            }
                        }
                    });
                }
            }
        });
    } else {
        mSimpleDraweeView.getHierarchy().setOverlayImage(null);
    }
    mSimpleDraweeView.setController(controllerBuilder.build());
}
Also used : Animatable(android.graphics.drawable.Animatable) ImageInfo(com.facebook.imagepipeline.image.ImageInfo) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ImageDecodeOptionsBuilder(com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder) PipelineDraweeControllerBuilder(com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)

Example 3 with ImageDecodeOptionsBuilder

use of com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder in project fresco by facebook.

the class ImageFormatOverrideExample method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
    ImageDecodeOptions imageDecodeOptionsWithCustomDecoder = new ImageDecodeOptionsBuilder().setCustomImageDecoder(CUSTOM_COLOR_DECODER).build();
    AbstractDraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(ImageRequestBuilder.newBuilderWithResourceId(R.raw.custom_color1).setImageDecodeOptions(imageDecodeOptionsWithCustomDecoder).build()).build();
    simpleDraweeView.setController(controller);
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) AbstractDraweeController(com.facebook.drawee.controller.AbstractDraweeController) ImageDecodeOptions(com.facebook.imagepipeline.common.ImageDecodeOptions) ImageDecodeOptionsBuilder(com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder)

Example 4 with ImageDecodeOptionsBuilder

use of com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder in project fresco by facebook.

the class ImagePipelineResizingFragment method reloadImage.

private void reloadImage(Uri imageUri, @Nullable ResizeOptions resizeOptions) {
    final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(imageUri).setResizeOptions(resizeOptions).setImageDecodeOptions(new ImageDecodeOptionsBuilder().build()).build();
    final DraweeController draweeController = Fresco.newDraweeControllerBuilder().setOldController(mDraweeMain.getController()).setImageRequest(imageRequest).build();
    mDraweeMain.setController(draweeController);
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) ImageDecodeOptionsBuilder(com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder)

Example 5 with ImageDecodeOptionsBuilder

use of com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder in project fresco by facebook.

the class ImageRequestTest method testCreatingRequestFromExistingRequest.

@Test
public void testCreatingRequestFromExistingRequest() {
    ImageRequest original = ImageRequestBuilder.newBuilderWithSource(Uri.parse("http://frescolib.org/image.jpg")).setCacheChoice(ImageRequest.CacheChoice.SMALL).setImageDecodeOptions(new ImageDecodeOptionsBuilder().build()).setLocalThumbnailPreviewsEnabled(true).setLowestPermittedRequestLevel(ImageRequest.RequestLevel.DISK_CACHE).setPostprocessor(new BasePostprocessor() {

        @Override
        public String getName() {
            return super.getName();
        }
    }).setProgressiveRenderingEnabled(true).setRequestListener(new RequestLoggingListener()).setResizeOptions(new ResizeOptions(20, 20)).setRotationOptions(RotationOptions.forceRotation(RotationOptions.ROTATE_90)).setRequestPriority(Priority.HIGH).build();
    ImageRequest copy = ImageRequestBuilder.fromRequest(original).build();
    assertThat(copy).isEqualTo(original);
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) RequestLoggingListener(com.facebook.imagepipeline.listener.RequestLoggingListener) ImageDecodeOptionsBuilder(com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder) Test(org.junit.Test)

Aggregations

ImageDecodeOptionsBuilder (com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder)5 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)2 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)2 Animatable (android.graphics.drawable.Animatable)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 TextView (android.widget.TextView)1 PipelineDraweeControllerBuilder (com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)1 AbstractDraweeController (com.facebook.drawee.controller.AbstractDraweeController)1 DraweeController (com.facebook.drawee.interfaces.DraweeController)1 ImageDecodeOptions (com.facebook.imagepipeline.common.ImageDecodeOptions)1 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)1 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)1 RequestLoggingListener (com.facebook.imagepipeline.listener.RequestLoggingListener)1 Test (org.junit.Test)1