@Override public void onCreate() { super.onCreate(); final Config config = Config.load(this); ImagePipelineConfig.Builder imagePipelineConfigBuilder = ImagePipelineConfig.newBuilder(this) .setResizeAndRotateEnabledForNetwork(false) .setDownsampleEnabled(config.downsampling); if (WebpSupportStatus.sIsWebpSupportRequired) { imagePipelineConfigBuilder.experiment().setWebpSupportEnabled(config.webpSupportEnabled); } if (config.decodingThreadCount == 0) { imagePipelineConfigBuilder.setExecutorSupplier( new DefaultExecutorSupplier(Const.NUMBER_OF_PROCESSORS)); } else { imagePipelineConfigBuilder.setExecutorSupplier( new ScrollPerfExecutorSupplier(Const.NUMBER_OF_PROCESSORS, config.decodingThreadCount)); } imagePipelineConfigBuilder.experiment().setDecodeCancellationEnabled(config.decodeCancellation); DraweeConfig draweeConfig = DraweeConfig.newBuilder() .setDrawDebugOverlay(config.draweeOverlayEnabled) .build(); Fresco.initialize(this, imagePipelineConfigBuilder.build(), draweeConfig); }
/** * Convenience method. */ public static MGImagesBitmap create(@NonNull String url, int width, int height, boolean circle, final boolean currentThread) { return MGImagesBitmap .builder() .url(url) .width(width) .height(height) .circle(circle) .executor(new Executor() { @Override public void execute(@NonNull final Runnable command) { if (currentThread) { command.run(); } else { new DefaultExecutorSupplier(1).forDecode(); } } }) .build(); }
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; }
private FrescoImageLoader(Context appContext) { mAppContext = appContext; mExecutorSupplier = new DefaultExecutorSupplier(Runtime.getRuntime().availableProcessors()); }