com.facebook.common.internal.Supplier Java Examples

The following examples show how to use com.facebook.common.internal.Supplier. 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: ImagePipeline.java    From fresco with MIT License 6 votes vote down vote up
/**
 * Returns a DataSource supplier that will on get submit the request for execution and return a
 * DataSource representing the pending results of the task.
 *
 * @param imageRequest the request to submit (what to execute).
 * @return a DataSource representing pending results and completion of the request
 */
public Supplier<DataSource<CloseableReference<PooledByteBuffer>>>
    getEncodedImageDataSourceSupplier(
        final ImageRequest imageRequest, final Object callerContext) {
  return new Supplier<DataSource<CloseableReference<PooledByteBuffer>>>() {
    @Override
    public DataSource<CloseableReference<PooledByteBuffer>> get() {
      return fetchEncodedImage(imageRequest, callerContext);
    }

    @Override
    public String toString() {
      return Objects.toStringHelper(this).add("uri", imageRequest.getSourceUri()).toString();
    }
  };
}
 
Example #2
Source File: AbstractDraweeControllerBuilder.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
/** Creates a data source supplier for the given image request. */
protected Supplier<DataSource<IMAGE>> getDataSourceSupplierForRequest(
    final REQUEST imageRequest,
    final boolean bitmapCacheOnly) {
  final Object callerContext = getCallerContext();
  return new Supplier<DataSource<IMAGE>>() {
    @Override
    public DataSource<IMAGE> get() {
      return getDataSourceForRequest(imageRequest, callerContext, bitmapCacheOnly);
    }
    @Override
    public String toString() {
      return Objects.toStringHelper(this)
          .add("request", imageRequest.toString())
          .toString();
    }
  };
}
 
Example #3
Source File: DraweeMocks.java    From fresco with MIT License 6 votes vote down vote up
/**
 * Creates a mock GenericDraweeHierarchyBuilder with stubbed build.
 *
 * @param drawableHierarchies drawable hierarchies to return on {@code build()}
 * @return mock GenericDraweeHierarchyBuilder
 */
public static GenericDraweeHierarchyBuilder mockBuilderOf(
    GenericDraweeHierarchy... drawableHierarchies) {
  GenericDraweeHierarchyBuilder builder =
      mock(GenericDraweeHierarchyBuilder.class, CALLS_REAL_METHODS);
  final Supplier<GenericDraweeHierarchy> gdhProvider = supplierOf(drawableHierarchies);
  doAnswer(
          new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
              return gdhProvider.get();
            }
          })
      .when(builder)
      .build();
  return builder;
}
 
Example #4
Source File: ImagePipeline.java    From fresco with MIT License 6 votes vote down vote up
/**
 * Returns a DataSource supplier that will on get submit the request for execution and return a
 * DataSource representing the pending results of the task.
 *
 * @param imageRequest the request to submit (what to execute).
 * @param callerContext the caller context of the caller of data source supplier
 * @param requestLevel which level to look down until for the image
 * @param requestListener additional image request listener independent of ImageRequest listeners
 * @param uiComponentId optional UI component ID requesting the image
 * @return a DataSource representing pending results and completion of the request
 */
public Supplier<DataSource<CloseableReference<CloseableImage>>> getDataSourceSupplier(
    final ImageRequest imageRequest,
    final Object callerContext,
    final ImageRequest.RequestLevel requestLevel,
    final @Nullable RequestListener requestListener,
    final @Nullable String uiComponentId) {
  return new Supplier<DataSource<CloseableReference<CloseableImage>>>() {
    @Override
    public DataSource<CloseableReference<CloseableImage>> get() {
      return fetchDecodedImage(
          imageRequest, callerContext, requestLevel, requestListener, uiComponentId);
    }

    @Override
    public String toString() {
      return Objects.toStringHelper(this).add("uri", imageRequest.getSourceUri()).toString();
    }
  };
}
 
Example #5
Source File: ImagePipelineConfigFactory.java    From ZhiHu-TopAnswer with Apache License 2.0 6 votes vote down vote up
/**
 * Configures disk and memory cache not to exceed common limits
 */
private static void configureCaches(
    ImagePipelineConfig.Builder configBuilder,
    Context context) {
  final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
      MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
      Integer.MAX_VALUE,                     // Max entries in the cache
      MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
      Integer.MAX_VALUE,                     // Max length of eviction queue
      Integer.MAX_VALUE);                    // Max cache entry size
  configBuilder
      .setBitmapMemoryCacheParamsSupplier(
          new Supplier<MemoryCacheParams>() {
            public MemoryCacheParams get() {
              return bitmapCacheParams;
            }
          })
      .setMainDiskCacheConfig(
          DiskCacheConfig.newBuilder(context)
              .setBaseDirectoryPath(context.getApplicationContext().getCacheDir())
              .setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
              .setMaxCacheSize(MAX_DISK_CACHE_SIZE)
              .build());
}
 
Example #6
Source File: AbstractDraweeControllerBuilder.java    From fresco with MIT License 6 votes vote down vote up
/** Creates a data source supplier for the given image request. */
protected Supplier<DataSource<IMAGE>> getDataSourceSupplierForRequest(
    final DraweeController controller,
    final String controllerId,
    final REQUEST imageRequest,
    final CacheLevel cacheLevel) {
  final Object callerContext = getCallerContext();
  return new Supplier<DataSource<IMAGE>>() {
    @Override
    public DataSource<IMAGE> get() {
      return getDataSourceForRequest(
          controller, controllerId, imageRequest, callerContext, cacheLevel);
    }

    @Override
    public String toString() {
      return Objects.toStringHelper(this).add("request", imageRequest.toString()).toString();
    }
  };
}
 
Example #7
Source File: BitmapCountingMemoryCacheFactory.java    From fresco with MIT License 6 votes vote down vote up
public static CountingMemoryCache<CacheKey, CloseableImage> get(
    Supplier<MemoryCacheParams> bitmapMemoryCacheParamsSupplier,
    MemoryTrimmableRegistry memoryTrimmableRegistry,
    CountingMemoryCache.CacheTrimStrategy trimStrategy,
    @Nullable CountingMemoryCache.EntryStateObserver<CacheKey> observer) {

  ValueDescriptor<CloseableImage> valueDescriptor =
      new ValueDescriptor<CloseableImage>() {
        @Override
        public int getSizeInBytes(CloseableImage value) {
          return value.getSizeInBytes();
        }
      };

  CountingMemoryCache<CacheKey, CloseableImage> countingCache =
      new CountingMemoryCache<>(
          valueDescriptor, trimStrategy, bitmapMemoryCacheParamsSupplier, observer);

  memoryTrimmableRegistry.registerMemoryTrimmable(countingCache);

  return countingCache;
}
 
Example #8
Source File: EncodedCountingMemoryCacheFactory.java    From fresco with MIT License 6 votes vote down vote up
public static CountingMemoryCache<CacheKey, PooledByteBuffer> get(
    Supplier<MemoryCacheParams> encodedMemoryCacheParamsSupplier,
    MemoryTrimmableRegistry memoryTrimmableRegistry) {

  ValueDescriptor<PooledByteBuffer> valueDescriptor =
      new ValueDescriptor<PooledByteBuffer>() {
        @Override
        public int getSizeInBytes(PooledByteBuffer value) {
          return value.size();
        }
      };

  CountingMemoryCache.CacheTrimStrategy trimStrategy = new NativeMemoryCacheTrimStrategy();

  CountingMemoryCache<CacheKey, PooledByteBuffer> countingCache =
      new CountingMemoryCache<>(
          valueDescriptor, trimStrategy, encodedMemoryCacheParamsSupplier, null);

  memoryTrimmableRegistry.registerMemoryTrimmable(countingCache);

  return countingCache;
}
 
Example #9
Source File: DefaultFrescoVitoProvider.java    From fresco with MIT License 6 votes vote down vote up
public DefaultFrescoVitoProvider(
    FrescoContext context,
    FrescoVitoConfig config,
    @Nullable Supplier<Boolean> debugOverlayEnabledSupplier) {
  if (!ImagePipelineFactory.hasBeenInitialized()) {
    throw new RuntimeException(
        "Fresco must be initialized before DefaultFrescoVitoProvider can be used!");
  }
  mFrescoVitoConfig = config;
  mFrescoVitoPrefetcher = context.getPrefetcher();
  mVitoImagePipeline =
      new VitoImagePipelineImpl(context.getImagePipeline(), context.getImagePipelineUtils());
  mFrescoController =
      new FrescoController2Impl(
          mFrescoVitoConfig,
          context.getHierarcher(),
          context.getLightweightBackgroundThreadExecutor(),
          context.getUiThreadExecutorService(),
          mVitoImagePipeline,
          null,
          debugOverlayEnabledSupplier == null
              ? new NoOpDebugOverlayFactory2()
              : new DefaultDebugOverlayFactory2(debugOverlayEnabledSupplier));
}
 
Example #10
Source File: ImagePipeline.java    From fresco with MIT License 6 votes vote down vote up
/**
 * Returns a DataSource supplier that will on get submit the request for execution and return a
 * DataSource representing the pending results of the task.
 *
 * @param imageRequest the request to submit (what to execute).
 * @param callerContext the caller context of the caller of data source supplier
 * @param requestLevel which level to look down until for the image
 * @param requestListener additional image request listener independent of ImageRequest listeners
 * @return a DataSource representing pending results and completion of the request
 */
public Supplier<DataSource<CloseableReference<CloseableImage>>> getDataSourceSupplier(
    final ImageRequest imageRequest,
    final Object callerContext,
    final ImageRequest.RequestLevel requestLevel,
    final @Nullable RequestListener requestListener) {
  return new Supplier<DataSource<CloseableReference<CloseableImage>>>() {
    @Override
    public DataSource<CloseableReference<CloseableImage>> get() {
      return fetchDecodedImage(imageRequest, callerContext, requestLevel, requestListener);
    }

    @Override
    public String toString() {
      return Objects.toStringHelper(this).add("uri", imageRequest.getSourceUri()).toString();
    }
  };
}
 
Example #11
Source File: PipelineDraweeControllerFactory.java    From fresco with MIT License 6 votes vote down vote up
public void init(
    Resources resources,
    DeferredReleaser deferredReleaser,
    DrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    MemoryCache<CacheKey, CloseableImage> memoryCache,
    @Nullable ImmutableList<DrawableFactory> drawableFactories,
    @Nullable Supplier<Boolean> debugOverlayEnabledSupplier) {
  mResources = resources;
  mDeferredReleaser = deferredReleaser;
  mAnimatedDrawableFactory = animatedDrawableFactory;
  mUiThreadExecutor = uiThreadExecutor;
  mMemoryCache = memoryCache;
  mDrawableFactories = drawableFactories;
  mDebugOverlayEnabledSupplier = debugOverlayEnabledSupplier;
}
 
Example #12
Source File: DataSourceTestUtils.java    From fresco with MIT License 6 votes vote down vote up
public void setUp() {
  mSrc1 = mock(DataSource.class);
  mSrc2 = mock(DataSource.class);
  mSrc3 = mock(DataSource.class);
  mDataSourceSupplier1 = mock(Supplier.class);
  mDataSourceSupplier2 = mock(Supplier.class);
  mDataSourceSupplier3 = mock(Supplier.class);
  when(mDataSourceSupplier1.get()).thenReturn(mSrc1);
  when(mDataSourceSupplier2.get()).thenReturn(mSrc2);
  when(mDataSourceSupplier3.get()).thenReturn(mSrc3);
  mDataSubscriber = mock(DataSubscriber.class);
  mExecutor = CallerThreadExecutor.getInstance();
  mInOrder =
      inOrder(
          mSrc1,
          mSrc2,
          mSrc3,
          mDataSourceSupplier1,
          mDataSourceSupplier2,
          mDataSourceSupplier3,
          mDataSubscriber);
  mSuppliers = Arrays.asList(mDataSourceSupplier1, mDataSourceSupplier2, mDataSourceSupplier3);
}
 
Example #13
Source File: ImagePipeline.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a DataSource supplier that will on get submit the request for execution and return a
 * DataSource representing the pending results of the task.
 * @param imageRequest the request to submit (what to execute).
 * @param bitmapCacheOnly whether to only look for the image in the bitmap cache
 * @return a DataSource representing pending results and completion of the request
 */
public Supplier<DataSource<CloseableReference<CloseableImage>>> getDataSourceSupplier(
    final ImageRequest imageRequest,
    final Object callerContext,
    final boolean bitmapCacheOnly) {
  return new Supplier<DataSource<CloseableReference<CloseableImage>>>() {
    @Override
    public DataSource<CloseableReference<CloseableImage>> get() {
      if (bitmapCacheOnly) {
        return fetchImageFromBitmapCache(imageRequest, callerContext);
      } else {
        return fetchDecodedImage(imageRequest, callerContext);
      }
    }
    @Override
    public String toString() {
      return Objects.toStringHelper(this)
          .add("uri", imageRequest.getSourceUri())
          .toString();
    }
  };
}
 
Example #14
Source File: ImagePipelineMultiUriHelper.java    From fresco with MIT License 6 votes vote down vote up
private static Supplier<DataSource<CloseableReference<CloseableImage>>>
    getImageRequestDataSourceSupplier(
        final ImagePipeline imagePipeline,
        final ImageRequest imageRequest,
        final Object callerContext,
        final ImageRequest.RequestLevel requestLevel,
        final RequestListener requestListener,
        final @Nullable String uiComponentId) {
  return new Supplier<DataSource<CloseableReference<CloseableImage>>>() {
    @Override
    public DataSource<CloseableReference<CloseableImage>> get() {
      return getImageRequestDataSource(
          imagePipeline, imageRequest, callerContext, requestListener, uiComponentId);
    }
  };
}
 
Example #15
Source File: AbstractDraweeControllerTest.java    From fresco with MIT License 5 votes vote down vote up
public FakeDraweeController(
    DeferredReleaser deferredReleaser,
    Executor uiThreadExecutor,
    Supplier<DataSource<FakeImage>> dataSourceSupplier,
    String id,
    Object callerContext) {
  super(deferredReleaser, uiThreadExecutor, id, callerContext);
  mDataSourceSupplier = dataSourceSupplier;
}
 
Example #16
Source File: AbstractDraweeControllerBuilder.java    From fresco with MIT License 5 votes vote down vote up
/** Gets the top-level data source supplier to be used by a controller. */
protected Supplier<DataSource<IMAGE>> obtainDataSourceSupplier(
    final DraweeController controller, final String controllerId) {
  if (mDataSourceSupplier != null) {
    return mDataSourceSupplier;
  }

  Supplier<DataSource<IMAGE>> supplier = null;

  // final image supplier;
  if (mImageRequest != null) {
    supplier = getDataSourceSupplierForRequest(controller, controllerId, mImageRequest);
  } else if (mMultiImageRequests != null) {
    supplier =
        getFirstAvailableDataSourceSupplier(
            controller, controllerId, mMultiImageRequests, mTryCacheOnlyFirst);
  }

  // increasing-quality supplier; highest-quality supplier goes first
  if (supplier != null && mLowResImageRequest != null) {
    List<Supplier<DataSource<IMAGE>>> suppliers = new ArrayList<>(2);
    suppliers.add(supplier);
    suppliers.add(getDataSourceSupplierForRequest(controller, controllerId, mLowResImageRequest));
    supplier = IncreasingQualityDataSourceSupplier.create(suppliers, false);
  }

  // no image requests; use null data source supplier
  if (supplier == null) {
    supplier = DataSources.getFailedDataSourceSupplier(NO_REQUEST_EXCEPTION);
  }

  return supplier;
}
 
Example #17
Source File: DynamicDefaultDiskStorage.java    From fresco with MIT License 5 votes vote down vote up
public DynamicDefaultDiskStorage(
    int version,
    Supplier<File> baseDirectoryPathSupplier,
    String baseDirectoryName,
    CacheErrorLogger cacheErrorLogger) {
  mVersion = version;
  mCacheErrorLogger = cacheErrorLogger;
  mBaseDirectoryPathSupplier = baseDirectoryPathSupplier;
  mBaseDirectoryName = baseDirectoryName;
  mCurrentState = new State(null, null);
}
 
Example #18
Source File: RetainingDataSourceSupplier.java    From fresco with MIT License 5 votes vote down vote up
public void replaceSupplier(Supplier<DataSource<T>> supplier) {
  mCurrentDataSourceSupplier = supplier;
  for (RetainingDataSource dataSource : mDataSources) {
    if (!dataSource.isClosed()) {
      dataSource.setSupplier(supplier);
    }
  }
}
 
Example #19
Source File: ImagePipeline.java    From fresco with MIT License 5 votes vote down vote up
public ImagePipeline(
    ProducerSequenceFactory producerSequenceFactory,
    Set<RequestListener> requestListeners,
    Set<RequestListener2> requestListener2s,
    Supplier<Boolean> isPrefetchEnabledSupplier,
    MemoryCache<CacheKey, CloseableImage> bitmapMemoryCache,
    MemoryCache<CacheKey, PooledByteBuffer> encodedMemoryCache,
    BufferedDiskCache mainBufferedDiskCache,
    BufferedDiskCache smallImageBufferedDiskCache,
    CacheKeyFactory cacheKeyFactory,
    ThreadHandoffProducerQueue threadHandoffProducerQueue,
    Supplier<Boolean> suppressBitmapPrefetchingSupplier,
    Supplier<Boolean> lazyDataSource,
    @Nullable CallerContextVerifier callerContextVerifier,
    ImagePipelineConfig config) {
  mIdCounter = new AtomicLong();
  mProducerSequenceFactory = producerSequenceFactory;
  mRequestListener = new ForwardingRequestListener(requestListeners);
  mRequestListener2 = new ForwardingRequestListener2(requestListener2s);
  mIsPrefetchEnabledSupplier = isPrefetchEnabledSupplier;
  mBitmapMemoryCache = bitmapMemoryCache;
  mEncodedMemoryCache = encodedMemoryCache;
  mMainBufferedDiskCache = mainBufferedDiskCache;
  mSmallImageBufferedDiskCache = smallImageBufferedDiskCache;
  mCacheKeyFactory = cacheKeyFactory;
  mThreadHandoffProducerQueue = threadHandoffProducerQueue;
  mSuppressBitmapPrefetchingSupplier = suppressBitmapPrefetchingSupplier;
  mLazyDataSource = lazyDataSource;
  mCallerContextVerifier = callerContextVerifier;
  mConfig = config;
}
 
Example #20
Source File: CountingMemoryCache.java    From fresco with MIT License 5 votes vote down vote up
public CountingMemoryCache(
    ValueDescriptor<V> valueDescriptor,
    CacheTrimStrategy cacheTrimStrategy,
    Supplier<MemoryCacheParams> memoryCacheParamsSupplier,
    @Nullable EntryStateObserver<K> entryStateObserver) {
  mValueDescriptor = valueDescriptor;
  mExclusiveEntries = new CountingLruMap<>(wrapValueDescriptor(valueDescriptor));
  mCachedEntries = new CountingLruMap<>(wrapValueDescriptor(valueDescriptor));
  mCacheTrimStrategy = cacheTrimStrategy;
  mMemoryCacheParamsSupplier = memoryCacheParamsSupplier;
  mMemoryCacheParams = mMemoryCacheParamsSupplier.get();
  mLastCacheParamsCheck = SystemClock.uptimeMillis();
  mEntryStateObserver = entryStateObserver;
}
 
Example #21
Source File: FirstAvailableDataSourceSupplier.java    From fresco with MIT License 5 votes vote down vote up
private boolean startNextDataSource() {
  Supplier<DataSource<T>> dataSourceSupplier = getNextSupplier();
  DataSource<T> dataSource = (dataSourceSupplier != null) ? dataSourceSupplier.get() : null;
  if (setCurrentDataSource(dataSource) && dataSource != null) {
    dataSource.subscribe(new InternalDataSubscriber(), CallerThreadExecutor.getInstance());
    return true;
  } else {
    closeSafely(dataSource);
    return false;
  }
}
 
Example #22
Source File: EmptyImageSource.java    From fresco with MIT License 5 votes vote down vote up
@Override
public Supplier<DataSource<CloseableReference<CloseableImage>>> createDataSourceSupplier(
    final ImagePipeline imagePipeline,
    final ImagePipelineUtils imagePipelineUtils,
    final ImageOptions imageOptions,
    final @Nullable Object callerContext,
    final @Nullable RequestListener requestListener,
    final String uiComponentId) {
  return new Supplier<DataSource<CloseableReference<CloseableImage>>>() {
    @Override
    public DataSource<CloseableReference<CloseableImage>> get() {
      return DataSources.immediateFailedDataSource(NO_REQUEST_EXCEPTION);
    }
  };
}
 
Example #23
Source File: DefaultDiskStorageTest.java    From fresco with MIT License 5 votes vote down vote up
private Supplier<DefaultDiskStorage> getStorageSupplier(final int version) {
  return new Supplier<DefaultDiskStorage>() {
    @Override
    public DefaultDiskStorage get() {
      return new DefaultDiskStorage(mDirectory, version, mock(CacheErrorLogger.class));
    }
  };
}
 
Example #24
Source File: DraweeMocks.java    From fresco with MIT License 5 votes vote down vote up
/**
 * Creates a supplier of T.
 *
 * @param values values to return on {@code get()}
 * @return supplier of T
 */
public static <T> Supplier<T> supplierOf(final T... values) {
  final AtomicInteger index = new AtomicInteger(0);
  return new Supplier<T>() {
    @Override
    public T get() {
      if (index.get() < values.length) {
        return values[index.getAndIncrement()];
      } else {
        return values[values.length - 1];
      }
    }
  };
}
 
Example #25
Source File: ImagePipelineMultiUriHelper.java    From fresco with MIT License 5 votes vote down vote up
private static Supplier<DataSource<CloseableReference<CloseableImage>>>
    getImageRequestDataSourceSupplier(
        final ImagePipeline imagePipeline,
        final ImageRequest imageRequest,
        final Object callerContext,
        final RequestListener requestListener,
        final @Nullable String uiComponentId) {
  return getImageRequestDataSourceSupplier(
      imagePipeline,
      imageRequest,
      callerContext,
      ImageRequest.RequestLevel.FULL_FETCH,
      requestListener,
      uiComponentId);
}
 
Example #26
Source File: ImagePerfControllerListener2.java    From fresco with MIT License 5 votes vote down vote up
public ImagePerfControllerListener2(
    MonotonicClock clock,
    ImagePerfState imagePerfState,
    ImagePerfNotifier imagePerfNotifier,
    Supplier<Boolean> asyncLogging) {
  mClock = clock;
  mImagePerfState = imagePerfState;
  mImagePerfNotifier = imagePerfNotifier;

  mAsyncLogging = asyncLogging;
}
 
Example #27
Source File: DiskStorageCacheTest.java    From fresco with MIT License 5 votes vote down vote up
public DiskStorageWithReadFailures(
    int version,
    Supplier<File> baseDirectoryPathSupplier,
    String baseDirectoryName,
    CacheErrorLogger cacheErrorLogger) {
  super(version, baseDirectoryPathSupplier, baseDirectoryName, cacheErrorLogger);
}
 
Example #28
Source File: ImagePipelineTest.java    From fresco with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  mPrefetchEnabledSupplier = mock(Supplier.class);
  mSuppressBitmapPrefetchingSupplier = mock(Supplier.class);
  mLazyDataSourceSupplier = mock(Supplier.class);
  when(mPrefetchEnabledSupplier.get()).thenReturn(true);
  when(mSuppressBitmapPrefetchingSupplier.get()).thenReturn(false);
  when(mLazyDataSourceSupplier.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),
          Sets.newHashSet(mock(RequestListener2.class)),
          mPrefetchEnabledSupplier,
          mBitmapMemoryCache,
          mEncodedMemoryCache,
          mMainDiskStorageCache,
          mSmallImageDiskStorageCache,
          mCacheKeyFactory,
          mThreadHandoffProducerQueue,
          mSuppressBitmapPrefetchingSupplier,
          mLazyDataSourceSupplier,
          null,
          mConfig);

  when(mImageRequest.getProgressiveRenderingEnabled()).thenReturn(true);
  when(mImageRequest.getPriority()).thenReturn(Priority.HIGH);
  when(mImageRequest.getLowestPermittedRequestLevel())
      .thenReturn(ImageRequest.RequestLevel.FULL_FETCH);
  when(mImageRequest.shouldDecodePrefetches()).thenReturn(null);
}
 
Example #29
Source File: VolleyDraweeController.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public VolleyDraweeController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    Executor uiThreadExecutor,
    Supplier<DataSource<Bitmap>> dataSourceSupplier,
    String id,
    Object callerContext) {
  super(deferredReleaser, uiThreadExecutor, id, callerContext);
  mResources = resources;
  init(dataSourceSupplier);
}
 
Example #30
Source File: PipelineDraweeController.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public PipelineDraweeController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    AnimatedDrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    Object callerContext) {
    super(deferredReleaser, uiThreadExecutor, id, callerContext);
  mResources = resources;
  mAnimatedDrawableFactory = animatedDrawableFactory;
  init(dataSourceSupplier);
}