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; }
public PipelineDraweeController newController( Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier, String id, CacheKey cacheKey, Object callerContext, @Nullable ImmutableList<DrawableFactory> customDrawableFactories) { Preconditions.checkState(mResources != null, "init() not called"); // Field values passed as arguments so that any subclass of PipelineDraweeControllerFactory // can simply override internalCreateController() and return a custom Drawee controller PipelineDraweeController controller = internalCreateController( mResources, mDeferredReleaser, mAnimatedDrawableFactory, mUiThreadExecutor, mMemoryCache, mDrawableFactories, customDrawableFactories, dataSourceSupplier, id, cacheKey, callerContext); if (mDebugOverlayEnabledSupplier != null) { controller.setDrawDebugOverlay(mDebugOverlayEnabledSupplier.get()); } return controller; }
protected PipelineDraweeController internalCreateController( Resources resources, DeferredReleaser deferredReleaser, DrawableFactory animatedDrawableFactory, Executor uiThreadExecutor, MemoryCache<CacheKey, CloseableImage> memoryCache, @Nullable ImmutableList<DrawableFactory> globalDrawableFactories, @Nullable ImmutableList<DrawableFactory> customDrawableFactories, Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier, String id, CacheKey cacheKey, Object callerContext) { PipelineDraweeController controller = new PipelineDraweeController( resources, deferredReleaser, animatedDrawableFactory, uiThreadExecutor, memoryCache, dataSourceSupplier, id, cacheKey, callerContext, globalDrawableFactories); controller.setCustomDrawableFactories(customDrawableFactories); return controller; }
public PipelineDraweeController( Resources resources, DeferredReleaser deferredReleaser, DrawableFactory animatedDrawableFactory, Executor uiThreadExecutor, MemoryCache<CacheKey, CloseableImage> memoryCache, Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier, String id, CacheKey cacheKey, Object callerContext) { this( resources, deferredReleaser, animatedDrawableFactory, uiThreadExecutor, memoryCache, dataSourceSupplier, id, cacheKey, callerContext, null); }
public PipelineDraweeController( Resources resources, DeferredReleaser deferredReleaser, DrawableFactory animatedDrawableFactory, Executor uiThreadExecutor, MemoryCache<CacheKey, CloseableImage> memoryCache, Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier, String id, CacheKey cacheKey, Object callerContext, @Nullable ImmutableList<DrawableFactory> globalDrawableFactories) { super(deferredReleaser, uiThreadExecutor, id, callerContext); mResources = resources; mAnimatedDrawableFactory = animatedDrawableFactory; mMemoryCache = memoryCache; mCacheKey = cacheKey; mGlobalDrawableFactories = globalDrawableFactories; init(dataSourceSupplier); }
private Drawable maybeCreateDrawableFromFactories( @Nullable ImmutableList<DrawableFactory> drawableFactories, CloseableImage closeableImage) { if (drawableFactories == null) { return null; } for (DrawableFactory factory : drawableFactories) { if (factory.supportsImageType(closeableImage)) { Drawable drawable = factory.createDrawable(closeableImage); if (drawable != null) { return drawable; } } } return null; }
/** * Add a custom drawable factory that will be used to create * Drawables for {@link com.facebook.imagepipeline.image.CloseableImage}s. * * @param factory the factory to use * @return the builder */ public Builder addCustomDrawableFactory(DrawableFactory factory) { if (mCustomDrawableFactories == null) { mCustomDrawableFactories = new ArrayList<>(); } mCustomDrawableFactories.add(factory); return this; }
/** * Initializes this controller with the new data source supplier, id and caller context. This * allows for reusing of the existing controller instead of instantiating a new one. This method * should be called when the controller is in detached state. * * @param dataSourceSupplier data source supplier * @param id unique id for this controller * @param callerContext tag and context for this controller */ public void initialize( Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier, String id, CacheKey cacheKey, Object callerContext, @Nullable ImmutableList<DrawableFactory> customDrawableFactories) { super.initialize(id, callerContext); init(dataSourceSupplier); mCacheKey = cacheKey; setCustomDrawableFactories(customDrawableFactories); }
@Nullable @Override public DrawableFactory getAnimatedDrawableFactory(Context context) { if (mAnimatedDrawableFactory == null) { mAnimatedDrawableFactory = createDrawableFactory(); } return mAnimatedDrawableFactory; }
public PipelineDraweeControllerBuilder setCustomDrawableFactories( @Nullable ImmutableList<DrawableFactory> customDrawableFactories) { mCustomDrawableFactories = customDrawableFactories; return getThis(); }
public PipelineDraweeControllerBuilder setCustomDrawableFactories( DrawableFactory... drawableFactories) { Preconditions.checkNotNull(drawableFactories); return setCustomDrawableFactories(ImmutableList.of(drawableFactories)); }
public PipelineDraweeControllerBuilder setCustomDrawableFactory(DrawableFactory drawableFactory) { Preconditions.checkNotNull(drawableFactory); return setCustomDrawableFactories(ImmutableList.of(drawableFactory)); }
@Nullable public ImmutableList<DrawableFactory> getCustomDrawableFactories() { return mCustomDrawableFactories; }
public void setCustomDrawableFactories( @Nullable ImmutableList<DrawableFactory> customDrawableFactories) { mCustomDrawableFactories = customDrawableFactories; }
@Nullable public DrawableFactory getAnimatedDrawableFactory(Context context) { AnimatedFactory animatedFactory = getAnimatedFactory(); return animatedFactory == null ? null : animatedFactory.getAnimatedDrawableFactory(context); }
public static DrawableFactory createDrawableFactory() { return new KeyframesDrawableFactory(); }
@Nullable DrawableFactory getAnimatedDrawableFactory(Context context);