com.facebook.imagepipeline.cache.CountingMemoryCache Java Examples

The following examples show how to use com.facebook.imagepipeline.cache.CountingMemoryCache. 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: AnimatedFrameCacheTest.java    From fresco with MIT License 6 votes vote down vote up
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  MemoryCacheParams params =
      new MemoryCacheParams(
          4 * ByteConstants.MB,
          256,
          Integer.MAX_VALUE,
          Integer.MAX_VALUE,
          Integer.MAX_VALUE,
          TimeUnit.MINUTES.toMillis(5));
  when(mMemoryCacheParamsSupplier.get()).thenReturn(params);
  CountingMemoryCache<CacheKey, CloseableImage> countingMemoryCache =
      BitmapCountingMemoryCacheFactory.get(
          mMemoryCacheParamsSupplier, mMemoryTrimmableRegistry, null);
  mCacheKey = new SimpleCacheKey("key");
  mAnimatedFrameCache = new AnimatedFrameCache(mCacheKey, countingMemoryCache);
  mFrame1 = CloseableReference.of(mock(CloseableImage.class));
  mFrame2 = CloseableReference.of(mock(CloseableImage.class));
}
 
Example #2
Source File: ExperimentalBitmapAnimationDrawableFactory.java    From fresco with MIT License 6 votes vote down vote up
public ExperimentalBitmapAnimationDrawableFactory(
    AnimatedDrawableBackendProvider animatedDrawableBackendProvider,
    ScheduledExecutorService scheduledExecutorServiceForUiThread,
    ExecutorService executorServiceForFramePreparing,
    MonotonicClock monotonicClock,
    PlatformBitmapFactory platformBitmapFactory,
    CountingMemoryCache<CacheKey, CloseableImage> backingCache,
    Supplier<Integer> cachingStrategySupplier,
    Supplier<Integer> numberOfFramesToPrepareSupplier) {
  mAnimatedDrawableBackendProvider = animatedDrawableBackendProvider;
  mScheduledExecutorServiceForUiThread = scheduledExecutorServiceForUiThread;
  mExecutorServiceForFramePreparing = executorServiceForFramePreparing;
  mMonotonicClock = monotonicClock;
  mPlatformBitmapFactory = platformBitmapFactory;
  mBackingCache = backingCache;
  mCachingStrategySupplier = cachingStrategySupplier;
  mNumberOfFramesToPrepareSupplier = numberOfFramesToPrepareSupplier;
}
 
Example #3
Source File: ImagePipelineFactory.java    From fresco with MIT License 5 votes vote down vote up
public CountingMemoryCache<CacheKey, PooledByteBuffer> getEncodedCountingMemoryCache() {
  if (mEncodedCountingMemoryCache == null) {
    mEncodedCountingMemoryCache =
        EncodedCountingMemoryCacheFactory.get(
            mConfig.getEncodedMemoryCacheParamsSupplier(), mConfig.getMemoryTrimmableRegistry());
  }
  return mEncodedCountingMemoryCache;
}
 
Example #4
Source File: ImagePipelineFactory.java    From fresco with MIT License 5 votes vote down vote up
public CountingMemoryCache<CacheKey, CloseableImage> getBitmapCountingMemoryCache() {
  if (mBitmapCountingMemoryCache == null) {
    mBitmapCountingMemoryCache =
        BitmapCountingMemoryCacheFactory.get(
            mConfig.getBitmapMemoryCacheParamsSupplier(),
            mConfig.getMemoryTrimmableRegistry(),
            mConfig.getBitmapMemoryCacheTrimStrategy(),
            mConfig.getBitmapMemoryCacheEntryStateObserver());
  }
  return mBitmapCountingMemoryCache;
}
 
Example #5
Source File: AnimatedFactoryProvider.java    From fresco with MIT License 5 votes vote down vote up
public static AnimatedFactory getAnimatedFactory(
    PlatformBitmapFactory platformBitmapFactory,
    ExecutorSupplier executorSupplier,
    CountingMemoryCache<CacheKey, CloseableImage> backingCache,
    boolean downscaleFrameToDrawableDimensions) {
  if (!sImplLoaded) {
    try {
      final Class<?> clazz =
          Class.forName("com.facebook.fresco.animation.factory.AnimatedFactoryV2Impl");
      final Constructor<?> constructor =
          clazz.getConstructor(
              PlatformBitmapFactory.class,
              ExecutorSupplier.class,
              CountingMemoryCache.class,
              Boolean.TYPE);
      sImpl =
          (AnimatedFactory)
              constructor.newInstance(
                  platformBitmapFactory,
                  executorSupplier,
                  backingCache,
                  downscaleFrameToDrawableDimensions);
    } catch (Throwable e) {
      // Head in the sand
    }
    if (sImpl != null) {
      sImplLoaded = true;
    }
  }
  return sImpl;
}
 
Example #6
Source File: AnimatedFrameCache.java    From fresco with MIT License 5 votes vote down vote up
public AnimatedFrameCache(
    CacheKey imageCacheKey, final CountingMemoryCache<CacheKey, CloseableImage> backingCache) {
  mImageCacheKey = imageCacheKey;
  mBackingCache = backingCache;
  mFreeItemsPool = new LinkedHashSet<>();
  mEntryStateObserver =
      new CountingMemoryCache.EntryStateObserver<CacheKey>() {
        @Override
        public void onExclusivityChanged(CacheKey key, boolean isExclusive) {
          AnimatedFrameCache.this.onReusabilityChange(key, isExclusive);
        }
      };
}
 
Example #7
Source File: AnimatedFactoryV2Impl.java    From fresco with MIT License 5 votes vote down vote up
@DoNotStrip
public AnimatedFactoryV2Impl(
    PlatformBitmapFactory platformBitmapFactory,
    ExecutorSupplier executorSupplier,
    CountingMemoryCache<CacheKey, CloseableImage> backingCache,
    boolean downscaleFrameToDrawableDimensions) {
  mPlatformBitmapFactory = platformBitmapFactory;
  mExecutorSupplier = executorSupplier;
  mBackingCache = backingCache;
  mDownscaleFrameToDrawableDimensions = downscaleFrameToDrawableDimensions;
}
 
Example #8
Source File: ImagePipelineFactory.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public CountingMemoryCache<CacheKey, PooledByteBuffer, Void> getEncodedCountingMemoryCache() {
  if (mEncodedCountingMemoryCache == null) {
    mEncodedCountingMemoryCache =
        EncodedCountingMemoryCacheFactory.get(
            mConfig.getEncodedMemoryCacheParamsSupplier(),
            mConfig.getMemoryTrimmableRegistry());
  }
  return mEncodedCountingMemoryCache;
}
 
Example #9
Source File: ImagePipelineFactory.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public CountingMemoryCache<BitmapMemoryCacheKey, CloseableImage, Void>
    getBitmapCountingMemoryCache() {
  if (mBitmapCountingMemoryCache == null) {
    mBitmapCountingMemoryCache =
        BitmapCountingMemoryCacheFactory.get(
            mConfig.getBitmapMemoryCacheParamsSupplier(),
            mConfig.getMemoryTrimmableRegistry());
  }
  return mBitmapCountingMemoryCache;
}
 
Example #10
Source File: ImagePipelineConfig.java    From fresco with MIT License 4 votes vote down vote up
public CountingMemoryCache.CacheTrimStrategy getBitmapMemoryCacheTrimStrategy() {
  return mBitmapMemoryCacheTrimStrategy;
}
 
Example #11
Source File: ImagePipelineConfig.java    From fresco with MIT License 4 votes vote down vote up
public CountingMemoryCache.EntryStateObserver<CacheKey> getBitmapMemoryCacheEntryStateObserver() {
  return mBitmapMemoryCacheEntryStateObserver;
}
 
Example #12
Source File: ImagePipelineConfig.java    From fresco with MIT License 4 votes vote down vote up
public Builder setBitmapMemoryCacheEntryStateObserver(
    CountingMemoryCache.EntryStateObserver<CacheKey> bitmapMemoryCacheEntryStateObserver) {
  mBitmapMemoryCacheEntryStateObserver = bitmapMemoryCacheEntryStateObserver;
  return this;
}
 
Example #13
Source File: FrescoUtils.java    From FrescoUtlis with Apache License 2.0 2 votes vote down vote up
@Override
public void registerEncodedMemoryCache(CountingMemoryCache<?, ?> countingMemoryCache) {

}
 
Example #14
Source File: FrescoUtils.java    From FrescoUtlis with Apache License 2.0 2 votes vote down vote up
@Override
public void registerBitmapMemoryCache(CountingMemoryCache<?, ?> countingMemoryCache) {

}
 
Example #15
Source File: FrescoCacheStatsTracker.java    From FrescoPlus with Apache License 2.0 2 votes vote down vote up
@Override
public void registerEncodedMemoryCache(CountingMemoryCache<?, ?> encodedMemoryCache) {

}
 
Example #16
Source File: FrescoCacheStatsTracker.java    From FrescoPlus with Apache License 2.0 2 votes vote down vote up
@Override
public void registerBitmapMemoryCache(CountingMemoryCache<?, ?> bitmapMemoryCache) {

}
 
Example #17
Source File: FrescoUtil.java    From MyImageUtil with Apache License 2.0 2 votes vote down vote up
@Override
public void registerEncodedMemoryCache(CountingMemoryCache<?, ?> countingMemoryCache) {

}
 
Example #18
Source File: FrescoUtil.java    From MyImageUtil with Apache License 2.0 2 votes vote down vote up
@Override
public void registerBitmapMemoryCache(CountingMemoryCache<?, ?> countingMemoryCache) {

}
 
Example #19
Source File: MyImageCacheStatsTracker.java    From ImageLoader with Apache License 2.0 2 votes vote down vote up
@Override
public void registerEncodedMemoryCache(CountingMemoryCache<?, ?> encodedMemoryCache) {

}
 
Example #20
Source File: MyImageCacheStatsTracker.java    From ImageLoader with Apache License 2.0 2 votes vote down vote up
@Override
public void registerBitmapMemoryCache(CountingMemoryCache<?, ?> bitmapMemoryCache) {

}