com.facebook.imagepipeline.core.DefaultExecutorSupplier Java Examples

The following examples show how to use com.facebook.imagepipeline.core.DefaultExecutorSupplier. 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: ExampleBitmapAnimationFactory.java    From fresco with MIT License 5 votes vote down vote up
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;
}
 
Example #2
Source File: ScrollPerfApplication.java    From fresco with MIT License 5 votes vote down vote up
@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();
  if (BuildConfig.FLAVOR == "noNativeCode") {
    imagePipelineConfigBuilder.setMemoryChunkType(MemoryChunkType.BUFFER_MEMORY);
    Fresco.initialize(this, imagePipelineConfigBuilder.build(), draweeConfig, false);
  } else {
    Fresco.initialize(this, imagePipelineConfigBuilder.build(), draweeConfig, true);
  }
}
 
Example #3
Source File: BigImageLoader.java    From ImageLoader with Apache License 2.0 4 votes vote down vote up
private BigImageLoader(Context appContext) {
    mAppContext = appContext;

    mExecutorSupplier = new DefaultExecutorSupplier(Runtime.getRuntime().availableProcessors());
    handler = new Handler(Looper.getMainLooper());
}