Search in sources :

Example 1 with SettableProducerContext

use of com.facebook.imagepipeline.producers.SettableProducerContext 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, Object callerContext) {
    final RequestListener requestListener = getRequestListenerForRequest(imageRequest);
    try {
        ImageRequest.RequestLevel lowestPermittedRequestLevel = ImageRequest.RequestLevel.getMax(imageRequest.getLowestPermittedRequestLevel(), lowestPermittedRequestLevelOnSubmit);
        SettableProducerContext settableProducerContext = new SettableProducerContext(imageRequest, generateUniqueFutureId(), requestListener, callerContext, lowestPermittedRequestLevel, /* isPrefetch */
        false, imageRequest.getProgressiveRenderingEnabled() || imageRequest.getMediaVariations() != null || !UriUtil.isNetworkUri(imageRequest.getSourceUri()), imageRequest.getPriority());
        return CloseableProducerToDataSourceAdapter.create(producerSequence, settableProducerContext, requestListener);
    } catch (Exception exception) {
        return DataSources.immediateFailedDataSource(exception);
    }
}
Also used : ForwardingRequestListener(com.facebook.imagepipeline.listener.ForwardingRequestListener) RequestListener(com.facebook.imagepipeline.listener.RequestListener) SettableProducerContext(com.facebook.imagepipeline.producers.SettableProducerContext) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) CancellationException(java.util.concurrent.CancellationException)

Example 2 with SettableProducerContext

use of com.facebook.imagepipeline.producers.SettableProducerContext in project fresco by facebook.

the class ImagePipeline method submitPrefetchRequest.

private DataSource<Void> submitPrefetchRequest(Producer<Void> producerSequence, ImageRequest imageRequest, ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit, Object callerContext, Priority priority) {
    final RequestListener requestListener = getRequestListenerForRequest(imageRequest);
    try {
        ImageRequest.RequestLevel lowestPermittedRequestLevel = ImageRequest.RequestLevel.getMax(imageRequest.getLowestPermittedRequestLevel(), lowestPermittedRequestLevelOnSubmit);
        SettableProducerContext settableProducerContext = new SettableProducerContext(imageRequest, generateUniqueFutureId(), requestListener, callerContext, lowestPermittedRequestLevel, /* isPrefetch */
        true, /* isIntermediateResultExpected */
        false, priority);
        return ProducerToDataSourceAdapter.create(producerSequence, settableProducerContext, requestListener);
    } catch (Exception exception) {
        return DataSources.immediateFailedDataSource(exception);
    }
}
Also used : ForwardingRequestListener(com.facebook.imagepipeline.listener.ForwardingRequestListener) RequestListener(com.facebook.imagepipeline.listener.RequestListener) SettableProducerContext(com.facebook.imagepipeline.producers.SettableProducerContext) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) CancellationException(java.util.concurrent.CancellationException)

Aggregations

ForwardingRequestListener (com.facebook.imagepipeline.listener.ForwardingRequestListener)2 RequestListener (com.facebook.imagepipeline.listener.RequestListener)2 SettableProducerContext (com.facebook.imagepipeline.producers.SettableProducerContext)2 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)2 CancellationException (java.util.concurrent.CancellationException)2