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; }
@Before public void setUp() { MockitoAnnotations.initMocks(this); MemoryCacheParams params = new MemoryCacheParams( 4 * ByteConstants.MB, 256, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); when(mMemoryCacheParamsSupplier.get()).thenReturn(params); CountingMemoryCache<CacheKey, CloseableImage> countingMemoryCache = BitmapCountingMemoryCacheFactory.get( mMemoryCacheParamsSupplier, mMemoryTrimmableRegistry, mPlatformBitmapFactory, true); mCacheKey = new SimpleCacheKey("key"); mAnimatedFrameCache = new AnimatedFrameCache(mCacheKey, countingMemoryCache); mFrame1 = CloseableReference.of(mock(CloseableImage.class)); mFrame2 = CloseableReference.of(mock(CloseableImage.class)); }
public static AnimatedFactory getAnimatedFactory( PlatformBitmapFactory platformBitmapFactory, ExecutorSupplier executorSupplier, CountingMemoryCache<CacheKey, CloseableImage> backingCache) { 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); sImpl = (AnimatedFactory) constructor.newInstance( platformBitmapFactory, executorSupplier, backingCache); } catch (Throwable e) { // Head in the sand } if (sImpl != null) { sImplLoaded = true; } } return sImpl; }
@DoNotStrip public AnimatedFactoryV2Impl( PlatformBitmapFactory platformBitmapFactory, ExecutorSupplier executorSupplier, CountingMemoryCache<CacheKey, CloseableImage> backingCache) { mPlatformBitmapFactory = platformBitmapFactory; mExecutorSupplier = executorSupplier; mBackingCache = backingCache; }
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); } }; }
public CountingMemoryCache<CacheKey, CloseableImage> getBitmapCountingMemoryCache() { if (mBitmapCountingMemoryCache == null) { mBitmapCountingMemoryCache = BitmapCountingMemoryCacheFactory.get( mConfig.getBitmapMemoryCacheParamsSupplier(), mConfig.getMemoryTrimmableRegistry(), getPlatformBitmapFactory(), mConfig.getExperiments().isExternalCreatedBitmapLogEnabled(), mConfig.getBitmapMemoryCacheTrimStrategy()); } return mBitmapCountingMemoryCache; }
public CountingMemoryCache<CacheKey, PooledByteBuffer> getEncodedCountingMemoryCache() { if (mEncodedCountingMemoryCache == null) { mEncodedCountingMemoryCache = EncodedCountingMemoryCacheFactory.get( mConfig.getEncodedMemoryCacheParamsSupplier(), mConfig.getMemoryTrimmableRegistry(), getPlatformBitmapFactory()); } return mEncodedCountingMemoryCache; }
public CountingMemoryCache.CacheTrimStrategy getBitmapMemoryCacheTrimStrategy() { return mBitmapMemoryCacheTrimStrategy; }
public Builder setBitmapMemoryCacheTrimStrategy( CountingMemoryCache.CacheTrimStrategy trimStrategy) { mBitmapMemoryCacheTrimStrategy = trimStrategy; return this; }
@Override public void registerBitmapMemoryCache(CountingMemoryCache<?, ?> countingMemoryCache) { }
@Override public void registerEncodedMemoryCache(CountingMemoryCache<?, ?> countingMemoryCache) { }
@Override public void registerBitmapMemoryCache(CountingMemoryCache<?, ?> bitmapMemoryCache) { }
@Override public void registerEncodedMemoryCache(CountingMemoryCache<?, ?> encodedMemoryCache) { }