com.facebook.common.internal.Sets Java Examples

The following examples show how to use com.facebook.common.internal.Sets. 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: BasePool.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new instance of the pool.
 * @param poolParams pool parameters
 * @param poolStatsTracker
 */
public BasePool(
    MemoryTrimmableRegistry memoryTrimmableRegistry,
    PoolParams poolParams,
    PoolStatsTracker poolStatsTracker) {
  mMemoryTrimmableRegistry = Preconditions.checkNotNull(memoryTrimmableRegistry);
  mPoolParams = Preconditions.checkNotNull(poolParams);
  mPoolStatsTracker = Preconditions.checkNotNull(poolStatsTracker);

  // initialize the buckets
  mBuckets = new SparseArray<Bucket<V>>();
  initBuckets(new SparseIntArray(0));

  mInUseValues = Sets.newIdentityHashSet();

  mFree = new Counter();
  mUsed = new Counter();
}
 
Example #2
Source File: CountingMemoryCache.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
public CountingMemoryCache(
    MemoryCacheIndex<K, V, S> memoryCacheIndex,
    ValueInfoCallback<V> valueInfoCallback,
    CacheTrimStrategy cacheTrimStrategy,
    Supplier<MemoryCacheParams> memoryCacheParamsSupplier) {
  mMemoryCacheIndex = memoryCacheIndex;
  mEvictionQueue = Sets.newLinkedHashSet();
  mCachedEntries = Maps.newHashMap();
  mOrphans = Maps.newHashMap();
  mValueInfoCallback = valueInfoCallback;
  mCacheTrimStrategy = cacheTrimStrategy;
  mMemoryCacheParamsSupplier = memoryCacheParamsSupplier;

  mMemoryCacheParams = mMemoryCacheParamsSupplier.get();
  mLastCacheParamsCheck = SystemClock.elapsedRealtime();
}
 
Example #3
Source File: BasePool.java    From fresco with MIT License 6 votes vote down vote up
/**
 * Creates a new instance of the pool.
 *
 * @param poolParams pool parameters
 * @param poolStatsTracker
 */
public BasePool(
    MemoryTrimmableRegistry memoryTrimmableRegistry,
    PoolParams poolParams,
    PoolStatsTracker poolStatsTracker) {
  mMemoryTrimmableRegistry = Preconditions.checkNotNull(memoryTrimmableRegistry);
  mPoolParams = Preconditions.checkNotNull(poolParams);
  mPoolStatsTracker = Preconditions.checkNotNull(poolStatsTracker);

  // initialize the buckets
  mBuckets = new SparseArray<Bucket<V>>();
  if (mPoolParams.fixBucketsReinitialization) {
    initBuckets();
  } else {
    legacyInitBuckets(new SparseIntArray(0));
  }

  mInUseValues = Sets.newIdentityHashSet();

  mFree = new Counter();
  mUsed = new Counter();
}
 
Example #4
Source File: ForwardingRequestListenerTest.java    From fresco with MIT License 5 votes vote down vote up
@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));
}
 
Example #5
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 #6
Source File: FrescoImageLoader.java    From FimiX8-RE with MIT License 4 votes vote down vote up
private static void configureLoggingListeners(Builder configBuilder) {
    configBuilder.setRequestListeners(Sets.newHashSet(new RequestLoggingListener()));
}
 
Example #7
Source File: MultiplexProducer.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
public Multiplexer(K key) {
  mConsumerContextPairs = Sets.newCopyOnWriteArraySet();
  mKey = key;
}
 
Example #8
Source File: DummyTrackingInUseBitmapPool.java    From fresco with MIT License 4 votes vote down vote up
public DummyTrackingInUseBitmapPool() {
  mInUseValues = Sets.newIdentityHashSet();
}
 
Example #9
Source File: MultiplexProducer.java    From fresco with MIT License 4 votes vote down vote up
public Multiplexer(K key) {
  mConsumerContextPairs = Sets.newCopyOnWriteArraySet();
  mKey = key;
}