Search in sources :

Example 1 with RequestListener2

use of com.facebook.imagepipeline.listener.RequestListener2 in project fresco by facebook.

the class ImagePipeline method submitPrefetchRequest.

private DataSource<Void> submitPrefetchRequest(Producer<Void> producerSequence, ImageRequest imageRequest, ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit, @Nullable Object callerContext, Priority priority, @Nullable RequestListener requestListener) {
    final RequestListener2 requestListener2 = new InternalRequestListener(getRequestListenerForRequest(imageRequest, requestListener), mRequestListener2);
    if (mCallerContextVerifier != null) {
        mCallerContextVerifier.verifyCallerContext(callerContext, true);
    }
    try {
        ImageRequest.RequestLevel lowestPermittedRequestLevel = ImageRequest.RequestLevel.getMax(imageRequest.getLowestPermittedRequestLevel(), lowestPermittedRequestLevelOnSubmit);
        SettableProducerContext settableProducerContext = new SettableProducerContext(imageRequest, generateUniqueFutureId(), requestListener2, callerContext, lowestPermittedRequestLevel, /* isPrefetch */
        true, /* isIntermediateResultExpected */
        false, priority, mConfig);
        return ProducerToDataSourceAdapter.create(producerSequence, settableProducerContext, requestListener2);
    } catch (Exception exception) {
        return DataSources.immediateFailedDataSource(exception);
    }
}
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)

Example 2 with RequestListener2

use of com.facebook.imagepipeline.listener.RequestListener2 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

ForwardingRequestListener2 (com.facebook.imagepipeline.listener.ForwardingRequestListener2)2 RequestListener2 (com.facebook.imagepipeline.listener.RequestListener2)2 InternalRequestListener (com.facebook.imagepipeline.producers.InternalRequestListener)2 SettableProducerContext (com.facebook.imagepipeline.producers.SettableProducerContext)2 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)2 CancellationException (java.util.concurrent.CancellationException)2