Search in sources :

Example 1 with DefaultSerialExecutorService

use of com.facebook.common.executors.DefaultSerialExecutorService in project fresco by facebook.

the class AnimatedFactoryV2Impl method createDrawableFactory.

private ExperimentalBitmapAnimationDrawableFactory createDrawableFactory() {
    Supplier<Integer> cachingStrategySupplier = new Supplier<Integer>() {

        @Override
        public Integer get() {
            return ExperimentalBitmapAnimationDrawableFactory.CACHING_STRATEGY_FRESCO_CACHE_NO_REUSING;
        }
    };
    final SerialExecutorService serialExecutorServiceForFramePreparing = mSerialExecutorService == null ? new DefaultSerialExecutorService(mExecutorSupplier.forDecode()) : mSerialExecutorService;
    Supplier<Integer> numberOfFramesToPrepareSupplier = new Supplier<Integer>() {

        @Override
        public Integer get() {
            return NUMBER_OF_FRAMES_TO_PREPARE;
        }
    };
    final Supplier<Boolean> useDeepEquals = Suppliers.BOOLEAN_FALSE;
    return new ExperimentalBitmapAnimationDrawableFactory(getAnimatedDrawableBackendProvider(), UiThreadImmediateExecutorService.getInstance(), serialExecutorServiceForFramePreparing, RealtimeSinceBootClock.get(), mPlatformBitmapFactory, mBackingCache, cachingStrategySupplier, numberOfFramesToPrepareSupplier, useDeepEquals);
}
Also used : DefaultSerialExecutorService(com.facebook.common.executors.DefaultSerialExecutorService) DefaultSerialExecutorService(com.facebook.common.executors.DefaultSerialExecutorService) SerialExecutorService(com.facebook.common.executors.SerialExecutorService) Supplier(com.facebook.common.internal.Supplier) ExecutorSupplier(com.facebook.imagepipeline.core.ExecutorSupplier)

Example 2 with DefaultSerialExecutorService

use of com.facebook.common.executors.DefaultSerialExecutorService in project fresco by facebook.

the class ExampleBitmapAnimationFactory method createColorBitmapAnimationBackend.

public static BitmapAnimationBackend createColorBitmapAnimationBackend(final int[] colors, final int animationDurationMs, final BitmapFrameCache bitmapFrameCache) {
    final PlatformBitmapFactory platformBitmapFactory = Fresco.getImagePipelineFactory().getPlatformBitmapFactory();
    final BitmapFrameRenderer bitmapFrameRenderer = new ColorAndFrameNumberRenderer(colors);
    final AnimationInformation animationInformation = new ColorListAnimationInformation(colors, animationDurationMs);
    final ExecutorService executorServiceForFramePreparer = new DefaultSerialExecutorService(new DefaultExecutorSupplier(1).forDecode());
    final BitmapFramePreparationStrategy framePreparationStrategy = new FixedNumberBitmapFramePreparationStrategy(NUMBER_OF_FRAMES_TO_PREPARE);
    final BitmapFramePreparer bitmapFramePreparer = new DefaultBitmapFramePreparer(platformBitmapFactory, bitmapFrameRenderer, Bitmap.Config.ARGB_8888, executorServiceForFramePreparer);
    BitmapAnimationBackend bitmapAnimationBackend = new BitmapAnimationBackend(platformBitmapFactory, bitmapFrameCache, animationInformation, bitmapFrameRenderer, framePreparationStrategy, bitmapFramePreparer);
    bitmapAnimationBackend.setFrameListener(new DebugBitmapAnimationFrameListener());
    return bitmapAnimationBackend;
}
Also used : DefaultSerialExecutorService(com.facebook.common.executors.DefaultSerialExecutorService) PlatformBitmapFactory(com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory) DefaultExecutorSupplier(com.facebook.imagepipeline.core.DefaultExecutorSupplier) DefaultBitmapFramePreparer(com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer) AnimationInformation(com.facebook.fresco.animation.backend.AnimationInformation) FixedNumberBitmapFramePreparationStrategy(com.facebook.fresco.animation.bitmap.preparation.FixedNumberBitmapFramePreparationStrategy) DefaultSerialExecutorService(com.facebook.common.executors.DefaultSerialExecutorService) ExecutorService(java.util.concurrent.ExecutorService) BitmapFramePreparationStrategy(com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparationStrategy) FixedNumberBitmapFramePreparationStrategy(com.facebook.fresco.animation.bitmap.preparation.FixedNumberBitmapFramePreparationStrategy) BitmapAnimationBackend(com.facebook.fresco.animation.bitmap.BitmapAnimationBackend) BitmapFrameRenderer(com.facebook.fresco.animation.bitmap.BitmapFrameRenderer) BitmapFramePreparer(com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparer) DefaultBitmapFramePreparer(com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer)

Example 3 with DefaultSerialExecutorService

use of com.facebook.common.executors.DefaultSerialExecutorService in project fresco by facebook.

the class AnimatedFactoryImpl method getAnimatedDrawableFactory.

@Override
public AnimatedDrawableFactory getAnimatedDrawableFactory(Context context) {
    if (mAnimatedDrawableFactory == null) {
        SerialExecutorService serialExecutorService = new DefaultSerialExecutorService(mExecutorSupplier.forDecode());
        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        mAnimatedDrawableFactory = buildAnimatedDrawableFactory(serialExecutorService, activityManager, getAnimatedDrawableUtil(), getAnimatedDrawableBackendProvider(), UiThreadImmediateExecutorService.getInstance(), RealtimeSinceBootClock.get(), context.getResources());
    }
    return mAnimatedDrawableFactory;
}
Also used : DefaultSerialExecutorService(com.facebook.common.executors.DefaultSerialExecutorService) DefaultSerialExecutorService(com.facebook.common.executors.DefaultSerialExecutorService) SerialExecutorService(com.facebook.common.executors.SerialExecutorService) ActivityManager(android.app.ActivityManager)

Aggregations

DefaultSerialExecutorService (com.facebook.common.executors.DefaultSerialExecutorService)3 SerialExecutorService (com.facebook.common.executors.SerialExecutorService)2 ActivityManager (android.app.ActivityManager)1 Supplier (com.facebook.common.internal.Supplier)1 AnimationInformation (com.facebook.fresco.animation.backend.AnimationInformation)1 BitmapAnimationBackend (com.facebook.fresco.animation.bitmap.BitmapAnimationBackend)1 BitmapFrameRenderer (com.facebook.fresco.animation.bitmap.BitmapFrameRenderer)1 BitmapFramePreparationStrategy (com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparationStrategy)1 BitmapFramePreparer (com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparer)1 DefaultBitmapFramePreparer (com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer)1 FixedNumberBitmapFramePreparationStrategy (com.facebook.fresco.animation.bitmap.preparation.FixedNumberBitmapFramePreparationStrategy)1 PlatformBitmapFactory (com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory)1 DefaultExecutorSupplier (com.facebook.imagepipeline.core.DefaultExecutorSupplier)1 ExecutorSupplier (com.facebook.imagepipeline.core.ExecutorSupplier)1 ExecutorService (java.util.concurrent.ExecutorService)1