Search in sources :

Example 6 with RequestListener

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

Example 7 with RequestListener

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

the class ImagePipelineTest method testLocalRequestListenerIsCalled.

@Test
public void testLocalRequestListenerIsCalled() {
    RequestListener localRequestListner = mock(RequestListener.class);
    when(mImageRequest.getRequestListener()).thenReturn(localRequestListner);
    Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class);
    when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest)).thenReturn(bitmapCacheSequence);
    mImagePipeline.fetchImageFromBitmapCache(mImageRequest, mCallerContext);
    verify(localRequestListner).onRequestStart(mImageRequest, mCallerContext, "0", false);
    verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
    verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
}
Also used : RequestListener(com.facebook.imagepipeline.listener.RequestListener) CloseableReference(com.facebook.common.references.CloseableReference) Test(org.junit.Test)

Example 8 with RequestListener

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

the class ImagePipelineConfigFactory method configureLoggingListeners.

private static void configureLoggingListeners(ImagePipelineConfig.Builder configBuilder) {
    Set<RequestListener> requestListeners = new HashSet<>();
    requestListeners.add(new RequestLoggingListener());
    configBuilder.setRequestListeners(requestListeners);
}
Also used : RequestListener(com.facebook.imagepipeline.listener.RequestListener) RequestLoggingListener(com.facebook.imagepipeline.listener.RequestLoggingListener) HashSet(java.util.HashSet)

Example 9 with RequestListener

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

the class DemoApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    FLog.setMinimumLoggingLevel(FLog.VERBOSE);
    Set<RequestListener> listeners = new HashSet<>();
    listeners.add(new RequestLoggingListener());
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this).setRequestListeners(listeners).build();
    DraweeConfig draweeConfig = DraweeConfig.newBuilder().setDrawDebugOverlay(DebugOverlayHelper.isDebugOverlayEnabled(this)).build();
    Fresco.initialize(this, config, draweeConfig);
}
Also used : RequestListener(com.facebook.imagepipeline.listener.RequestListener) ImagePipelineConfig(com.facebook.imagepipeline.core.ImagePipelineConfig) RequestLoggingListener(com.facebook.imagepipeline.listener.RequestLoggingListener) DraweeConfig(com.facebook.drawee.backends.pipeline.DraweeConfig) HashSet(java.util.HashSet)

Example 10 with RequestListener

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

the class ZoomableApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    FLog.setMinimumLoggingLevel(FLog.VERBOSE);
    Set<RequestListener> listeners = new HashSet<>();
    listeners.add(new RequestLoggingListener());
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this).setRequestListeners(listeners).build();
    Fresco.initialize(this, config);
}
Also used : RequestListener(com.facebook.imagepipeline.listener.RequestListener) ImagePipelineConfig(com.facebook.imagepipeline.core.ImagePipelineConfig) RequestLoggingListener(com.facebook.imagepipeline.listener.RequestLoggingListener) HashSet(java.util.HashSet)

Aggregations

RequestListener (com.facebook.imagepipeline.listener.RequestListener)11 RequestLoggingListener (com.facebook.imagepipeline.listener.RequestLoggingListener)8 HashSet (java.util.HashSet)8 ImagePipelineConfig (com.facebook.imagepipeline.core.ImagePipelineConfig)7 DraweeConfig (com.facebook.drawee.backends.pipeline.DraweeConfig)2 ForwardingRequestListener (com.facebook.imagepipeline.listener.ForwardingRequestListener)2 SettableProducerContext (com.facebook.imagepipeline.producers.SettableProducerContext)2 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)2 CancellationException (java.util.concurrent.CancellationException)2 Supplier (com.facebook.common.internal.Supplier)1 CloseableReference (com.facebook.common.references.CloseableReference)1 ShowcaseMediaIdExtractor (com.facebook.fresco.samples.showcase.imagepipeline.ShowcaseMediaIdExtractor)1 Test (org.junit.Test)1