Java 类com.facebook.imagepipeline.listener.RequestListener 实例源码

项目:GitHub    文件:ImagePipeline.java   
public ImagePipeline(
    ProducerSequenceFactory producerSequenceFactory,
    Set<RequestListener> requestListeners,
    Supplier<Boolean> isPrefetchEnabledSupplier,
    MemoryCache<CacheKey, CloseableImage> bitmapMemoryCache,
    MemoryCache<CacheKey, PooledByteBuffer> encodedMemoryCache,
    BufferedDiskCache mainBufferedDiskCache,
    BufferedDiskCache smallImageBufferedDiskCache,
    CacheKeyFactory cacheKeyFactory,
    ThreadHandoffProducerQueue threadHandoffProducerQueue,
    Supplier<Boolean> suppressBitmapPrefetchingSupplier) {
  mIdCounter = new AtomicLong();
  mProducerSequenceFactory = producerSequenceFactory;
  mRequestListener = new ForwardingRequestListener(requestListeners);
  mIsPrefetchEnabledSupplier = isPrefetchEnabledSupplier;
  mBitmapMemoryCache = bitmapMemoryCache;
  mEncodedMemoryCache = encodedMemoryCache;
  mMainBufferedDiskCache = mainBufferedDiskCache;
  mSmallImageBufferedDiskCache = smallImageBufferedDiskCache;
  mCacheKeyFactory = cacheKeyFactory;
  mThreadHandoffProducerQueue = threadHandoffProducerQueue;
  mSuppressBitmapPrefetchingSupplier = suppressBitmapPrefetchingSupplier;
}
项目:RNLearn_Project1    文件:FrescoModule.java   
/**
 * Get the default Fresco configuration builder.
 * Allows adding of configuration options in addition to the default values.
 *
 * @return {@link ImagePipelineConfig.Builder} that has been initialized with default values
 */
public static ImagePipelineConfig.Builder getDefaultConfigBuilder(ReactContext context) {
  HashSet<RequestListener> requestListeners = new HashSet<>();
  requestListeners.add(new SystraceRequestListener());

  OkHttpClient client = OkHttpClientProvider.createClient();

  // make sure to forward cookies for any requests via the okHttpClient
  // so that image requests to endpoints that use cookies still work
  CookieJarContainer container = (CookieJarContainer) client.cookieJar();
  ForwardingCookieHandler handler = new ForwardingCookieHandler(context);
  container.setCookieJar(new JavaNetCookieJar(handler));

  return OkHttpImagePipelineConfigFactory
    .newBuilder(context.getApplicationContext(), client)
    .setNetworkFetcher(new ReactOkHttpNetworkFetcher(client))
    .setDownsampleEnabled(false)
    .setRequestListeners(requestListeners);
}
项目:RNLearn_Project1    文件:FrescoModule.java   
/**
 * Get the default Fresco configuration builder.
 * Allows adding of configuration options in addition to the default values.
 *
 * @return {@link ImagePipelineConfig.Builder} that has been initialized with default values
 */
public static ImagePipelineConfig.Builder getDefaultConfigBuilder(ReactContext context) {
  HashSet<RequestListener> requestListeners = new HashSet<>();
  requestListeners.add(new SystraceRequestListener());

  OkHttpClient client = OkHttpClientProvider.createClient();

  // make sure to forward cookies for any requests via the okHttpClient
  // so that image requests to endpoints that use cookies still work
  CookieJarContainer container = (CookieJarContainer) client.cookieJar();
  ForwardingCookieHandler handler = new ForwardingCookieHandler(context);
  container.setCookieJar(new JavaNetCookieJar(handler));

  return OkHttpImagePipelineConfigFactory
    .newBuilder(context.getApplicationContext(), client)
    .setNetworkFetcher(new ReactOkHttpNetworkFetcher(client))
    .setDownsampleEnabled(false)
    .setRequestListeners(requestListeners);
}
项目:ReactNativeSignatureExample    文件:FrescoModule.java   
private static ImagePipelineConfig getDefaultConfig(
    Context context,
    @Nullable RequestListener listener,
    @Nullable DiskCacheConfig diskCacheConfig) {
  HashSet<RequestListener> requestListeners = new HashSet<>();
  requestListeners.add(new SystraceRequestListener());
  if (listener != null) {
    requestListeners.add(listener);
  }

  OkHttpClient okHttpClient = OkHttpClientProvider.getOkHttpClient();
  ImagePipelineConfig.Builder builder =
      OkHttpImagePipelineConfigFactory.newBuilder(context.getApplicationContext(), okHttpClient);

  builder
      .setDownsampleEnabled(false)
      .setRequestListeners(requestListeners);

  if (diskCacheConfig != null) {
    builder.setMainDiskCacheConfig(diskCacheConfig);
  }

  return builder.build();
}
项目:react-native-ibeacon-android    文件:FrescoModule.java   
private static ImagePipelineConfig getDefaultConfig(
    Context context,
    @Nullable RequestListener listener,
    @Nullable DiskCacheConfig diskCacheConfig) {
  HashSet<RequestListener> requestListeners = new HashSet<>();
  requestListeners.add(new SystraceRequestListener());
  if (listener != null) {
    requestListeners.add(listener);
  }

  OkHttpClient okHttpClient = OkHttpClientProvider.getOkHttpClient();
  ImagePipelineConfig.Builder builder =
      OkHttpImagePipelineConfigFactory.newBuilder(context.getApplicationContext(), okHttpClient);

  builder
      .setDownsampleEnabled(false)
      .setRequestListeners(requestListeners);

  if (diskCacheConfig != null) {
    builder.setMainDiskCacheConfig(diskCacheConfig);
  }

  return builder.build();
}
项目:react-native-box-loaders    文件:FrescoModule.java   
private static ImagePipelineConfig getDefaultConfig(
    Context context,
    @Nullable RequestListener listener,
    @Nullable DiskCacheConfig diskCacheConfig) {
  HashSet<RequestListener> requestListeners = new HashSet<>();
  requestListeners.add(new SystraceRequestListener());
  if (listener != null) {
    requestListeners.add(listener);
  }

  OkHttpClient okHttpClient = OkHttpClientProvider.getOkHttpClient();
  ImagePipelineConfig.Builder builder =
      OkHttpImagePipelineConfigFactory.newBuilder(context.getApplicationContext(), okHttpClient);

  builder
      .setDownsampleEnabled(false)
      .setRequestListeners(requestListeners);

  if (diskCacheConfig != null) {
    builder.setMainDiskCacheConfig(diskCacheConfig);
  }

  return builder.build();
}
项目:fresco    文件:ImagePipeline.java   
public ImagePipeline(
    ProducerSequenceFactory producerSequenceFactory,
    Set<RequestListener> requestListeners,
    Supplier<Boolean> isPrefetchEnabledSupplier,
    MemoryCache<CacheKey, CloseableImage> bitmapMemoryCache,
    MemoryCache<CacheKey, PooledByteBuffer> encodedMemoryCache,
    BufferedDiskCache mainBufferedDiskCache,
    BufferedDiskCache smallImageBufferedDiskCache,
    CacheKeyFactory cacheKeyFactory,
    ThreadHandoffProducerQueue threadHandoffProducerQueue,
    Supplier<Boolean> suppressBitmapPrefetchingSupplier) {
  mIdCounter = new AtomicLong();
  mProducerSequenceFactory = producerSequenceFactory;
  mRequestListener = new ForwardingRequestListener(requestListeners);
  mIsPrefetchEnabledSupplier = isPrefetchEnabledSupplier;
  mBitmapMemoryCache = bitmapMemoryCache;
  mEncodedMemoryCache = encodedMemoryCache;
  mMainBufferedDiskCache = mainBufferedDiskCache;
  mSmallImageBufferedDiskCache = smallImageBufferedDiskCache;
  mCacheKeyFactory = cacheKeyFactory;
  mThreadHandoffProducerQueue = threadHandoffProducerQueue;
  mSuppressBitmapPrefetchingSupplier = suppressBitmapPrefetchingSupplier;
}
项目:GitHub    文件:CloseableProducerToDataSourceAdapter.java   
public static <T> DataSource<CloseableReference<T>> create(
    Producer<CloseableReference<T>> producer,
    SettableProducerContext settableProducerContext,
    RequestListener listener) {
  return new CloseableProducerToDataSourceAdapter<T>(
      producer, settableProducerContext, listener);
}
项目:GitHub    文件:AbstractProducerToDataSourceAdapter.java   
protected AbstractProducerToDataSourceAdapter(
    Producer<T> producer,
    SettableProducerContext settableProducerContext,
    RequestListener requestListener) {
  mSettableProducerContext = settableProducerContext;
  mRequestListener = requestListener;
  mRequestListener.onRequestStart(
      settableProducerContext.getImageRequest(),
      mSettableProducerContext.getCallerContext(),
      mSettableProducerContext.getId(),
      mSettableProducerContext.isPrefetch());
  producer.produceResults(createConsumer(), settableProducerContext);
}
项目:GitHub    文件:ProducerToDataSourceAdapter.java   
public static <T> DataSource<T> create(
    Producer<T> producer,
    SettableProducerContext settableProducerContext,
    RequestListener listener) {
  return new ProducerToDataSourceAdapter<T>(
      producer,
      settableProducerContext,
      listener);
}
项目:GitHub    文件:ImagePipeline.java   
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);
  }
}
项目:GitHub    文件:ImagePipeline.java   
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);
  }
}
项目:GitHub    文件:ForwardingRequestListenerTest.java   
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mRequestListener1 = mock(RequestListener.class);
  mRequestListener2 = mock(RequestListener.class);
  mRequestListener3 = mock(RequestListener.class);
  when(mRequestListener1.requiresExtraMap(mRequestId)).thenReturn(false);
  when(mRequestListener2.requiresExtraMap(mRequestId)).thenReturn(false);
  when(mRequestListener3.requiresExtraMap(mRequestId)).thenReturn(false);
  mListenerManager = new ForwardingRequestListener(
      Sets.newHashSet(mRequestListener1, mRequestListener2, mRequestListener3));
}
项目:GitHub    文件:ImagePipelineTest.java   
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  mPrefetchEnabledSupplier = mock(Supplier.class);
  mSuppressBitmapPrefetchingSupplier = mock(Supplier.class);
  when(mPrefetchEnabledSupplier.get()).thenReturn(true);
  when(mSuppressBitmapPrefetchingSupplier.get()).thenReturn(false);
  mRequestListener1 = mock(RequestListener.class);
  mRequestListener2 = mock(RequestListener.class);
  mBitmapMemoryCache = mock(MemoryCache.class);
  mEncodedMemoryCache = mock(MemoryCache.class);
  mMainDiskStorageCache = mock(BufferedDiskCache.class);
  mSmallImageDiskStorageCache = mock(BufferedDiskCache.class);
  mThreadHandoffProducerQueue= mock(ThreadHandoffProducerQueue.class);
  mImagePipeline = new ImagePipeline(
      mProducerSequenceFactory,
      Sets.newHashSet(mRequestListener1, mRequestListener2),
      mPrefetchEnabledSupplier,
      mBitmapMemoryCache,
      mEncodedMemoryCache,
      mMainDiskStorageCache,
      mSmallImageDiskStorageCache,
      mCacheKeyFactory,
      mThreadHandoffProducerQueue,
      mSuppressBitmapPrefetchingSupplier);

  when(mImageRequest.getProgressiveRenderingEnabled()).thenReturn(true);
  when(mImageRequest.getPriority()).thenReturn(Priority.HIGH);
  when(mImageRequest.getLowestPermittedRequestLevel())
      .thenReturn(ImageRequest.RequestLevel.FULL_FETCH);
}
项目:GitHub    文件:ImagePipelineTest.java   
@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);
}
项目:GitHub    文件:AnimationApplication.java   
@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);
}
项目:GitHub    文件:ZoomableApplication.java   
@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);
}
项目:CommentGallery    文件:GalleryApplication.java   
@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);
}
项目:WindowImageView    文件:MyApp.java   
@Override
public void onCreate() {
    super.onCreate();
    Set<RequestListener> requestListeners = new HashSet<>();
    requestListeners.add(new RequestLoggingListener());
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            // other setters
            .setRequestListeners(requestListeners)
            .build();
    Fresco.initialize(this, config);
    FLog.setMinimumLoggingLevel(FLog.VERBOSE);
}
项目:Ironman    文件:FrescoModule.java   
private static ImagePipelineConfig getDefaultConfig(Context context) {
  HashSet<RequestListener> requestListeners = new HashSet<>();
  requestListeners.add(new SystraceRequestListener());

  return OkHttpImagePipelineConfigFactory
    .newBuilder(context.getApplicationContext(), OkHttpClientProvider.getOkHttpClient())
    .setDownsampleEnabled(false)
    .setRequestListeners(requestListeners)
    .build();
}
项目:gank-examples    文件:MyApplication.java   
private void initialize() {
        mApplication = this;
        mContext = this.getApplicationContext();
        mResources = this.getResources();
        Builder builder = Logcat.newBuilder();
        builder.logCatLogLevel(Logcat.SHOW_VERBOSE_LOG);
//        builder.logCatLogLevel(Logcat.NOT_SHOW_LOG);
//        Logcat.initialize(this, builder.build());
        Logcat.initialize(this);
        if (IS_DEBUG_ACTIVITYLIFE) {
            mActivityLifecycle = new MyActivityLifecycle();
            this.registerActivityLifecycleCallbacks(mActivityLifecycle);
        }
        //
        Set<RequestListener> requestListeners = new HashSet<>();
        requestListeners.add(new RequestLoggingListener());
        ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
                // other setters
                .setRequestListeners(requestListeners)
                //配置图片磁盘缓存
                .setMainDiskCacheConfig(DiskCacheConfig.newBuilder(this)
                        .setBaseDirectoryName("image") //父目录下的文件夹名
                        .setBaseDirectoryPath(StorageUtils.getAppCacheFile(this)) //保存父目录
                        .build())
                .build();
        Fresco.initialize(this, config);
        FLog.setMinimumLoggingLevel(FLog.DEBUG);

        try {
            CrashHandler crashHandler = CrashHandler.getInstance();
            crashHandler.init(this, Config.CARSH_LOG_PATH);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
项目:SneezeReader    文件:ReaderApplication.java   
/**
 * 初始化fresco
 */
private void initFresco() {

    Set<RequestListener> requestListeners = new HashSet<>();
    requestListeners.add(new RequestLoggingListener());
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setBitmapsConfig(Bitmap.Config.ARGB_8888)
            .setDownsampleEnabled(true)
            .setNetworkFetcher(new OkHttpNetworkFetcher(new OkHttpClient()))
            .setRequestListeners(requestListeners)
            .build();
    Fresco.initialize(this, config);
}
项目:mobile-buy-sdk-android    文件:BaseApplication.java   
private void initFresco() {
  final ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(this);

  File cacheDir = getExternalCacheDir();
  if (cacheDir == null) {
    cacheDir = getCacheDir();
  }

  final DiskCacheConfig.Builder mainDiskCacheConfigBuilder = DiskCacheConfig.newBuilder(this);
  mainDiskCacheConfigBuilder.setBaseDirectoryName("image_cache");
  mainDiskCacheConfigBuilder.setBaseDirectoryPath(cacheDir);
  mainDiskCacheConfigBuilder.setMaxCacheSize(100 * 1024 * 1024);
  mainDiskCacheConfigBuilder.setVersion(1);
  configBuilder.setMainDiskCacheConfig(mainDiskCacheConfigBuilder.build());

  final ImagePipelineConfig.Builder config = ImagePipelineConfig.newBuilder(this);
  if (BuildConfig.DEBUG) {
    final Set<RequestListener> requestListeners = new HashSet<>();
    requestListeners.add(new RequestLoggingListener());
    config.setRequestListeners(requestListeners);

    FLog.setMinimumLoggingLevel(FLog.VERBOSE);
  }
  configBuilder.setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry);

  Fresco.initialize(this, config.build());
}
项目:fresco    文件:CloseableProducerToDataSourceAdapter.java   
public static <T> DataSource<CloseableReference<T>> create(
    Producer<CloseableReference<T>> producer,
    SettableProducerContext settableProducerContext,
    RequestListener listener) {
  return new CloseableProducerToDataSourceAdapter<T>(
      producer, settableProducerContext, listener);
}
项目:fresco    文件:AbstractProducerToDataSourceAdapter.java   
protected AbstractProducerToDataSourceAdapter(
    Producer<T> producer,
    SettableProducerContext settableProducerContext,
    RequestListener requestListener) {
  mSettableProducerContext = settableProducerContext;
  mRequestListener = requestListener;
  mRequestListener.onRequestStart(
      settableProducerContext.getImageRequest(),
      mSettableProducerContext.getCallerContext(),
      mSettableProducerContext.getId(),
      mSettableProducerContext.isPrefetch());
  producer.produceResults(createConsumer(), settableProducerContext);
}
项目:fresco    文件:ProducerToDataSourceAdapter.java   
public static <T> DataSource<T> create(
    Producer<T> producer,
    SettableProducerContext settableProducerContext,
    RequestListener listener) {
  return new ProducerToDataSourceAdapter<T>(
      producer,
      settableProducerContext,
      listener);
}
项目:fresco    文件:ImagePipeline.java   
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);
  }
}
项目:fresco    文件:ImagePipeline.java   
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);
  }
}
项目:fresco    文件:ForwardingRequestListenerTest.java   
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mRequestListener1 = mock(RequestListener.class);
  mRequestListener2 = mock(RequestListener.class);
  mRequestListener3 = mock(RequestListener.class);
  when(mRequestListener1.requiresExtraMap(mRequestId)).thenReturn(false);
  when(mRequestListener2.requiresExtraMap(mRequestId)).thenReturn(false);
  when(mRequestListener3.requiresExtraMap(mRequestId)).thenReturn(false);
  mListenerManager = new ForwardingRequestListener(
      Sets.newHashSet(mRequestListener1, mRequestListener2, mRequestListener3));
}
项目:fresco    文件:ImagePipelineTest.java   
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  mPrefetchEnabledSupplier = mock(Supplier.class);
  mSuppressBitmapPrefetchingSupplier = mock(Supplier.class);
  when(mPrefetchEnabledSupplier.get()).thenReturn(true);
  when(mSuppressBitmapPrefetchingSupplier.get()).thenReturn(false);
  mRequestListener1 = mock(RequestListener.class);
  mRequestListener2 = mock(RequestListener.class);
  mBitmapMemoryCache = mock(MemoryCache.class);
  mEncodedMemoryCache = mock(MemoryCache.class);
  mMainDiskStorageCache = mock(BufferedDiskCache.class);
  mSmallImageDiskStorageCache = mock(BufferedDiskCache.class);
  mThreadHandoffProducerQueue= mock(ThreadHandoffProducerQueue.class);
  mImagePipeline = new ImagePipeline(
      mProducerSequenceFactory,
      Sets.newHashSet(mRequestListener1, mRequestListener2),
      mPrefetchEnabledSupplier,
      mBitmapMemoryCache,
      mEncodedMemoryCache,
      mMainDiskStorageCache,
      mSmallImageDiskStorageCache,
      mCacheKeyFactory,
      mThreadHandoffProducerQueue,
      mSuppressBitmapPrefetchingSupplier);

  when(mImageRequest.getProgressiveRenderingEnabled()).thenReturn(true);
  when(mImageRequest.getPriority()).thenReturn(Priority.HIGH);
  when(mImageRequest.getLowestPermittedRequestLevel())
      .thenReturn(ImageRequest.RequestLevel.FULL_FETCH);
}
项目:fresco    文件:ImagePipelineTest.java   
@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);
}
项目:fresco    文件:AnimationApplication.java   
@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);
}
项目:fresco    文件:ZoomableApplication.java   
@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);
}
项目:GitHub    文件:CloseableProducerToDataSourceAdapter.java   
private CloseableProducerToDataSourceAdapter(
    Producer<CloseableReference<T>> producer,
    SettableProducerContext settableProducerContext,
    RequestListener listener) {
  super(producer, settableProducerContext, listener);
}
项目:GitHub    文件:ProducerToDataSourceAdapter.java   
private ProducerToDataSourceAdapter(
    Producer<T> producer,
    SettableProducerContext settableProducerContext,
    RequestListener listener) {
  super(producer, settableProducerContext, listener);
}
项目:GitHub    文件:ImageRequestBuilder.java   
/**
 * @return the additional request listener to use for this image request
 */
public @Nullable RequestListener getRequestListener() {
  return mRequestListener;
}
项目:GitHub    文件:ImageRequest.java   
public @Nullable RequestListener getRequestListener() {
  return mRequestListener;
}
项目:GitHub    文件:ImagePipelineConfig.java   
public Set<RequestListener> getRequestListeners() {
  return Collections.unmodifiableSet(mRequestListeners);
}
项目:GitHub    文件:ImagePipelineConfig.java   
public Builder setRequestListeners(Set<RequestListener> requestListeners) {
  mRequestListeners = requestListeners;
  return this;
}
项目:GitHub    文件:ImagePipeline.java   
private RequestListener getRequestListenerForRequest(ImageRequest imageRequest) {
  if (imageRequest.getRequestListener() == null) {
    return mRequestListener;
  }
  return new ForwardingRequestListener(mRequestListener, imageRequest.getRequestListener());
}