Search in sources :

Example 71 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.

the class ImagePipelinePostProcessorFragment method setPostprocessor.

private void setPostprocessor(Postprocessor postprocessor) {
    final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri).setPostprocessor(postprocessor).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)

Example 72 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest 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 73 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.

the class ImageFormatProgressiveJpegFragment method setImageUri.

private void setImageUri(Uri uri) {
    mDebugOutput.setText("");
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setProgressiveRenderingEnabled(mProgressiveRenderingEnabled).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setRetainImageOnFailure(true).setPerfDataListener(mImagePerfDataListener).setControllerListener(new BaseControllerListener<ImageInfo>() {

        @Override
        public void onFinalImageSet(String id, @javax.annotation.Nullable ImageInfo imageInfo, @javax.annotation.Nullable Animatable animatable) {
            if (imageInfo != null) {
                QualityInfo qualityInfo = imageInfo.getQualityInfo();
                logScan(qualityInfo, true);
            }
        }

        @Override
        public void onIntermediateImageSet(String id, @javax.annotation.Nullable ImageInfo imageInfo) {
            if (imageInfo != null) {
                QualityInfo qualityInfo = imageInfo.getQualityInfo();
                logScan(qualityInfo, false);
            }
        }

        @Override
        public void onIntermediateImageFailed(String id, Throwable throwable) {
            mDebugOutput.append(String.format(Locale.getDefault(), "onIntermediateImageFailed, %s\n", throwable.getMessage()));
        }
    }).build();
    mSimpleDraweeView.setController(controller);
}
Also used : BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Animatable(android.graphics.drawable.Animatable) QualityInfo(com.facebook.imagepipeline.image.QualityInfo) ImageInfo(com.facebook.imagepipeline.image.ImageInfo)

Example 74 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.

the class PipelineDraweeControllerBuilder method getCacheKey.

@Nullable
private CacheKey getCacheKey() {
    final ImageRequest imageRequest = getImageRequest();
    final CacheKeyFactory cacheKeyFactory = mImagePipeline.getCacheKeyFactory();
    CacheKey cacheKey = null;
    if (cacheKeyFactory != null && imageRequest != null) {
        if (imageRequest.getPostprocessor() != null) {
            cacheKey = cacheKeyFactory.getPostprocessedBitmapCacheKey(imageRequest, getCallerContext());
        } else {
            cacheKey = cacheKeyFactory.getBitmapCacheKey(imageRequest, getCallerContext());
        }
    }
    return cacheKey;
}
Also used : CacheKeyFactory(com.facebook.imagepipeline.cache.CacheKeyFactory) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) CacheKey(com.facebook.cache.common.CacheKey) Nullable(javax.annotation.Nullable)

Example 75 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.

the class ImagePipeline method submitFetchRequest.

private <T> DataSource<CloseableReference<T>> submitFetchRequest(Producer<CloseableReference<T>> producerSequence, ImageRequest imageRequest, ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit, @Nullable Object callerContext, @Nullable RequestListener requestListener, @Nullable String uiComponentId) {
    if (FrescoSystrace.isTracing()) {
        FrescoSystrace.beginSection("ImagePipeline#submitFetchRequest");
    }
    final RequestListener2 requestListener2 = new InternalRequestListener(getRequestListenerForRequest(imageRequest, requestListener), mRequestListener2);
    if (mCallerContextVerifier != null) {
        mCallerContextVerifier.verifyCallerContext(callerContext, false);
    }
    try {
        ImageRequest.RequestLevel lowestPermittedRequestLevel = ImageRequest.RequestLevel.getMax(imageRequest.getLowestPermittedRequestLevel(), lowestPermittedRequestLevelOnSubmit);
        SettableProducerContext settableProducerContext = new SettableProducerContext(imageRequest, generateUniqueFutureId(), uiComponentId, requestListener2, callerContext, lowestPermittedRequestLevel, /* isPrefetch */
        false, imageRequest.getProgressiveRenderingEnabled() || !UriUtil.isNetworkUri(imageRequest.getSourceUri()), imageRequest.getPriority(), mConfig);
        return CloseableProducerToDataSourceAdapter.create(producerSequence, settableProducerContext, requestListener2);
    } catch (Exception exception) {
        return DataSources.immediateFailedDataSource(exception);
    } finally {
        if (FrescoSystrace.isTracing()) {
            FrescoSystrace.endSection();
        }
    }
}
Also used : SettableProducerContext(com.facebook.imagepipeline.producers.SettableProducerContext) ForwardingRequestListener2(com.facebook.imagepipeline.listener.ForwardingRequestListener2) RequestListener2(com.facebook.imagepipeline.listener.RequestListener2) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) CancellationException(java.util.concurrent.CancellationException) InternalRequestListener(com.facebook.imagepipeline.producers.InternalRequestListener)

Aggregations

ImageRequest (com.facebook.imagepipeline.request.ImageRequest)100 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)26 DraweeController (com.facebook.drawee.interfaces.DraweeController)25 CloseableReference (com.facebook.common.references.CloseableReference)24 Uri (android.net.Uri)18 ImagePipeline (com.facebook.imagepipeline.core.ImagePipeline)17 Test (org.junit.Test)14 Bitmap (android.graphics.Bitmap)13 CacheKey (com.facebook.cache.common.CacheKey)12 File (java.io.File)11 DataSource (com.facebook.datasource.DataSource)10 BaseBitmapDataSubscriber (com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber)9 CloseableImage (com.facebook.imagepipeline.image.CloseableImage)8 ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)8 Animatable (android.graphics.drawable.Animatable)7 PipelineDraweeController (com.facebook.drawee.backends.pipeline.PipelineDraweeController)7 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)7 ImageOptions (com.facebook.fresco.vito.options.ImageOptions)7 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)7 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)6