void attach(BitmapUpdateListener listener) { mBitmapUpdateListener = listener; mAttachCounter++; if (mAttachCounter != 1) { // this is a secondary attach, ignore it, only updating Bitmap boundaries if needed. Bitmap bitmap = getBitmap(); if (bitmap != null) { listener.onSecondaryAttach(bitmap); } return; } listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD_START); Assertions.assertCondition(mDataSource == null); Assertions.assertCondition(mImageRef == null); // Submit the request ImagePipeline imagePipeline = ImagePipelineFactory.getInstance().getImagePipeline(); mDataSource = imagePipeline.fetchDecodedImage(mImageRequest, RCTImageView.getCallerContext()); mDataSource.subscribe(this, UiThreadImmediateExecutorService.getInstance()); }
public PipelineDraweeControllerBuilderSupplier( Context context, ImagePipelineFactory imagePipelineFactory, Set<ControllerListener> boundControllerListeners, @Nullable DraweeConfig draweeConfig) { mContext = context; mImagePipeline = imagePipelineFactory.getImagePipeline(); if (draweeConfig != null && draweeConfig.getPipelineDraweeControllerFactory() != null) { mPipelineDraweeControllerFactory = draweeConfig.getPipelineDraweeControllerFactory(); } else { mPipelineDraweeControllerFactory = new PipelineDraweeControllerFactory(); } mPipelineDraweeControllerFactory.init( context.getResources(), DeferredReleaser.getInstance(), imagePipelineFactory.getAnimatedDrawableFactory(context), UiThreadImmediateExecutorService.getInstance(), mImagePipeline.getBitmapMemoryCache(), draweeConfig != null ? draweeConfig.getCustomDrawableFactories() : null, draweeConfig != null ? draweeConfig.getDebugOverlayEnabledSupplier() : null); mBoundControllerListeners = boundControllerListeners; }
public VolleyDraweeControllerBuilderSupplier( Context context, ImageLoader imageLoader, Set<ControllerListener> boundControllerListeners) { mContext = context; mImageLoader = imageLoader; mVolleyDraweeControllerFactory = new VolleyDraweeControllerFactory( context.getResources(), DeferredReleaser.getInstance(), UiThreadImmediateExecutorService.getInstance()); mBoundControllerListeners = boundControllerListeners; }
private ExperimentalBitmapAnimationDrawableFactory createDrawableFactory() { Supplier<Integer> cachingStrategySupplier = new Supplier<Integer>() { @Override public Integer get() { return ExperimentalBitmapAnimationDrawableFactory.CACHING_STRATEGY_FRESCO_CACHE_NO_REUSING; } }; final SerialExecutorService serialExecutorServiceForFramePreparing = new DefaultSerialExecutorService(mExecutorSupplier.forDecode()); Supplier<Integer> numberOfFramesToPrepareSupplier = new Supplier<Integer>() { @Override public Integer get() { return NUMBER_OF_FRAMES_TO_PREPARE; } }; return new ExperimentalBitmapAnimationDrawableFactory( getAnimatedDrawableBackendProvider(), UiThreadImmediateExecutorService.getInstance(), serialExecutorServiceForFramePreparing, RealtimeSinceBootClock.get(), mPlatformBitmapFactory, mBackingCache, cachingStrategySupplier, numberOfFramesToPrepareSupplier); }
/** * Wraps the given animation backend with an activity check. * When no frame has been drawn for more than 2 seconds, an inactivity toast message will * be displayed. * * @param context the context to be used for displaying the toast message * @param animationBackend the backend to wrap with the inactivity check * @return the wrapped backend to use */ public static AnimationBackend wrapAnimationBackendWithInactivityCheck( final Context context, final AnimationBackend animationBackend) { AnimationBackendDelegateWithInactivityCheck.InactivityListener inactivityListener = new AnimationBackendDelegateWithInactivityCheck.InactivityListener() { @Override public void onInactive() { // Forward the inactive callback to the backend if needed if (animationBackend instanceof AnimationBackendDelegateWithInactivityCheck.InactivityListener) { ((AnimationBackendDelegateWithInactivityCheck.InactivityListener) animationBackend) .onInactive(); } Toast.makeText( context, "Animation backend inactive.", Toast.LENGTH_SHORT) .show(); } }; return createForBackend( animationBackend, inactivityListener, RealtimeSinceBootClock.get(), UiThreadImmediateExecutorService.getInstance()); }
public void get() { ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(imageUrl)) .build(); ImagePipeline imagePipeline = Fresco.getImagePipeline(); DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(request, WikipediaApp.getInstance()); dataSource.subscribe(new BitmapDataSubscriber(), UiThreadImmediateExecutorService.getInstance()); }