Java Code Examples for com.facebook.imagepipeline.request.ImageRequest#getPostprocessor()
The following examples show how to use
com.facebook.imagepipeline.request.ImageRequest#getPostprocessor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultCacheKeyFactory.java From fresco with MIT License | 6 votes |
@Override public CacheKey getPostprocessedBitmapCacheKey( ImageRequest request, @Nullable Object callerContext) { final Postprocessor postprocessor = request.getPostprocessor(); final CacheKey postprocessorCacheKey; final String postprocessorName; if (postprocessor != null) { postprocessorCacheKey = postprocessor.getPostprocessorCacheKey(); postprocessorName = postprocessor.getClass().getName(); } else { postprocessorCacheKey = null; postprocessorName = null; } return new BitmapMemoryCacheKey( getCacheKeySourceUri(request.getSourceUri()).toString(), request.getResizeOptions(), request.getRotationOptions(), request.getImageDecodeOptions(), postprocessorCacheKey, postprocessorName, callerContext); }
Example 2
Source File: ProducerSequenceFactory.java From fresco with MIT License | 6 votes |
/** * Returns a sequence that can be used for a request for a decoded image. * * @param imageRequest the request that will be submitted * @return the sequence that should be used to process the request */ public Producer<CloseableReference<CloseableImage>> getDecodedImageProducerSequence( ImageRequest imageRequest) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("ProducerSequenceFactory#getDecodedImageProducerSequence"); } Producer<CloseableReference<CloseableImage>> pipelineSequence = getBasicDecodedImageSequence(imageRequest); if (imageRequest.getPostprocessor() != null) { pipelineSequence = getPostprocessorSequence(pipelineSequence); } if (mUseBitmapPrepareToDraw) { pipelineSequence = getBitmapPrepareSequence(pipelineSequence); } if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } return pipelineSequence; }
Example 3
Source File: ImagePipeline.java From fresco with MIT License | 6 votes |
/** @return {@link CacheKey} for doing bitmap cache lookups in the pipeline. */ @Nullable public CacheKey getCacheKey(@Nullable ImageRequest imageRequest, @Nullable Object callerContext) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("ImagePipeline#getCacheKey"); } final CacheKeyFactory cacheKeyFactory = mCacheKeyFactory; CacheKey cacheKey = null; if (cacheKeyFactory != null && imageRequest != null) { if (imageRequest.getPostprocessor() != null) { cacheKey = cacheKeyFactory.getPostprocessedBitmapCacheKey(imageRequest, callerContext); } else { cacheKey = cacheKeyFactory.getBitmapCacheKey(imageRequest, callerContext); } } if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } return cacheKey; }
Example 4
Source File: ProducerSequenceFactory.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
/** * Returns a sequence that can be used for a request for a decoded image. * * @param imageRequest the request that will be submitted * @return the sequence that should be used to process the request */ public Producer<CloseableReference<CloseableImage>> getDecodedImageProducerSequence( ImageRequest imageRequest) { Producer<CloseableReference<CloseableImage>> pipelineSequence = getBasicDecodedImageSequence(imageRequest); if (imageRequest.getPostprocessor() != null) { return getPostprocessorSequence(pipelineSequence); } else { return pipelineSequence; } }
Example 5
Source File: PipelineDraweeControllerBuilder.java From fresco with MIT License | 5 votes |
private @Nullable 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; }
Example 6
Source File: PostprocessedBitmapMemoryCacheProducer.java From fresco with MIT License | 4 votes |
@Override public void produceResults( final Consumer<CloseableReference<CloseableImage>> consumer, final ProducerContext producerContext) { final ProducerListener2 listener = producerContext.getProducerListener(); final ImageRequest imageRequest = producerContext.getImageRequest(); final Object callerContext = producerContext.getCallerContext(); // If there's no postprocessor or the postprocessor doesn't require caching, forward results. final Postprocessor postprocessor = imageRequest.getPostprocessor(); if (postprocessor == null || postprocessor.getPostprocessorCacheKey() == null) { mInputProducer.produceResults(consumer, producerContext); return; } listener.onProducerStart(producerContext, getProducerName()); final CacheKey cacheKey = mCacheKeyFactory.getPostprocessedBitmapCacheKey(imageRequest, callerContext); CloseableReference<CloseableImage> cachedReference = mMemoryCache.get(cacheKey); if (cachedReference != null) { listener.onProducerFinishWithSuccess( producerContext, getProducerName(), listener.requiresExtraMap(producerContext, getProducerName()) ? ImmutableMap.of(VALUE_FOUND, "true") : null); listener.onUltimateProducerReached(producerContext, PRODUCER_NAME, true); producerContext.putOriginExtra("memory_bitmap", "postprocessed"); consumer.onProgressUpdate(1.0f); consumer.onNewResult(cachedReference, Consumer.IS_LAST); cachedReference.close(); } else { final boolean isRepeatedProcessor = postprocessor instanceof RepeatedPostprocessor; final boolean isMemoryCachedEnabled = producerContext.getImageRequest().isMemoryCacheEnabled(); Consumer<CloseableReference<CloseableImage>> cachedConsumer = new CachedPostprocessorConsumer( consumer, cacheKey, isRepeatedProcessor, mMemoryCache, isMemoryCachedEnabled); listener.onProducerFinishWithSuccess( producerContext, getProducerName(), listener.requiresExtraMap(producerContext, getProducerName()) ? ImmutableMap.of(VALUE_FOUND, "false") : null); mInputProducer.produceResults(cachedConsumer, producerContext); } }