com.facebook.drawee.components.DeferredReleaser Java Examples

The following examples show how to use com.facebook.drawee.components.DeferredReleaser. 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: PipelineDraweeControllerFactory.java    From fresco with MIT License 6 votes vote down vote up
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;
}
 
Example #2
Source File: FrescoControllerImpl.java    From fresco with MIT License 6 votes vote down vote up
@Override
public void onDetach(FrescoState frescoState) {
  if (FrescoSystrace.isTracing()) {
    FrescoSystrace.beginSection("FrescoControllerImpl#onDetach");
  }
  frescoState.setAttached(false);

  if (mFrescoContext.getExperiments().closeDatasource()) {
    DeferredReleaser.getInstance().scheduleDeferredRelease(frescoState);
  }

  if (frescoState.getFrescoDrawable() != null) {
    frescoState.getFrescoDrawable().close();
    frescoState.setFrescoDrawable(null);
  }
  CloseableReference.closeSafely(frescoState.getCachedImage());

  if (mControllerListener2 != null) {
    mControllerListener2.onRelease(VitoUtils.getStringId(frescoState.getId()), null);
  }
  frescoState.onRelease(frescoState.getId());
  if (FrescoSystrace.isTracing()) {
    FrescoSystrace.endSection();
  }
}
 
Example #3
Source File: AbstractDraweeControllerTest.java    From fresco with MIT License 6 votes vote down vote up
@Before
public void setUp() {
  mDeferredReleaser = mock(DeferredReleaser.class);
  mCallerContext = mock(Object.class);
  mDataSourceSupplier = mock(Supplier.class);
  mDraweeHierarchy = mock(SettableDraweeHierarchy.class);
  mUiThreadExecutor = CallerThreadExecutor.getInstance();
  mController =
      new FakeDraweeController(
          mDeferredReleaser, mUiThreadExecutor, mDataSourceSupplier, "id", mCallerContext);
  doAnswer(
          new Answer<Object>() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
              ((DeferredReleaser.Releasable) invocation.getArguments()[0]).release();
              return null;
            }
          })
      .when(mDeferredReleaser)
      .scheduleDeferredRelease(any(DeferredReleaser.Releasable.class));
  when(mDataSourceSupplier.get()).thenReturn(SimpleDataSource.<FakeImage>create());
}
 
Example #4
Source File: AbstractDraweeController.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public AbstractDraweeController(
    DeferredReleaser deferredReleaser,
    Executor uiThreadImmediateExecutor,
    String id,
    Object callerContext) {
  mDeferredReleaser = deferredReleaser;
  mUiThreadImmediateExecutor = uiThreadImmediateExecutor;
  init(id, callerContext);
}
 
Example #5
Source File: PipelineDraweeControllerBuilderSupplier.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public PipelineDraweeControllerBuilderSupplier(
    Context context,
    ImagePipelineFactory imagePipelineFactory,
    Set<ControllerListener> boundControllerListeners) {
  mContext = context;
  mImagePipeline = imagePipelineFactory.getImagePipeline();
  mPipelineDraweeControllerFactory = new PipelineDraweeControllerFactory(
      context.getResources(),
      DeferredReleaser.getInstance(),
      imagePipelineFactory.getAnimatedDrawableFactory(),
      UiThreadImmediateExecutorService.getInstance());
  mBoundControllerListeners = boundControllerListeners;
}
 
Example #6
Source File: PipelineDraweeControllerFactory.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public PipelineDraweeControllerFactory(
    Resources resources,
    DeferredReleaser deferredReleaser,
    AnimatedDrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor) {
  mResources = resources;
  mDeferredReleaser = deferredReleaser;
  mAnimatedDrawableFactory = animatedDrawableFactory;
  mUiThreadExecutor = uiThreadExecutor;
}
 
Example #7
Source File: PipelineDraweeController.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public PipelineDraweeController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    AnimatedDrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    Object callerContext) {
    super(deferredReleaser, uiThreadExecutor, id, callerContext);
  mResources = resources;
  mAnimatedDrawableFactory = animatedDrawableFactory;
  init(dataSourceSupplier);
}
 
Example #8
Source File: VolleyDraweeController.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public VolleyDraweeController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    Executor uiThreadExecutor,
    Supplier<DataSource<Bitmap>> dataSourceSupplier,
    String id,
    Object callerContext) {
  super(deferredReleaser, uiThreadExecutor, id, callerContext);
  mResources = resources;
  init(dataSourceSupplier);
}
 
Example #9
Source File: VolleyDraweeControllerBuilderSupplier.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public VolleyDraweeControllerBuilderSupplier(
    Context context,
    ImageLoader imageLoader,
    Set<ControllerListener> boundControllerListeners) {
  mContext = context;
  mImageLoader = imageLoader;
  mVolleyDraweeControllerFactory = new VolleyDraweeControllerFactory(
      context.getResources(),
      DeferredReleaser.getInstance(),
      UiThreadExecutorService.getInstance());
  mBoundControllerListeners = boundControllerListeners;
}
 
Example #10
Source File: VolleyDraweeControllerFactory.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public VolleyDraweeControllerFactory(
    Resources resources,
    DeferredReleaser deferredReleaser,
    Executor uiThreadExecutor) {
  mResources = resources;
  mDeferredReleaser = deferredReleaser;
  mUiThreadExecutor = uiThreadExecutor;
}
 
Example #11
Source File: DraweeSpan.java    From drawee-text-view with Apache License 2.0 5 votes vote down vote up
/**
 * Use {@link Builder} to build a DraweeSpan.
 */
private DraweeSpan(String uri, int verticalAlignment, Drawable placeHolder, boolean showAnim) {
    super(verticalAlignment);
    mImageUri = uri;
    mShouldShowAnim = showAnim;
    mDeferredReleaser = DeferredReleaser.getInstance();
    mPlaceHolder = placeHolder;
    // create forwarding drawable with placeholder
    mActualDrawable = new ForwardingDrawable(mPlaceHolder);
}
 
Example #12
Source File: PipelineDraweeControllerBuilderSupplier.java    From fresco with MIT License 5 votes vote down vote up
public PipelineDraweeControllerBuilderSupplier(
    Context context,
    ImagePipelineFactory imagePipelineFactory,
    Set<ControllerListener> boundControllerListeners,
    Set<ControllerListener2> boundControllerListeners2,
    @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;
  mBoundControllerListeners2 = boundControllerListeners2;

  mDefaultImagePerfDataListener =
      draweeConfig != null ? draweeConfig.getImagePerfDataListener() : null;
}
 
Example #13
Source File: PipelineDraweeControllerFactory.java    From fresco with MIT License 5 votes vote down vote up
protected PipelineDraweeController internalCreateController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    DrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    MemoryCache<CacheKey, CloseableImage> memoryCache,
    @Nullable ImmutableList<DrawableFactory> drawableFactories) {
  return new PipelineDraweeController(
      resources,
      deferredReleaser,
      animatedDrawableFactory,
      uiThreadExecutor,
      memoryCache,
      drawableFactories);
}
 
Example #14
Source File: PipelineDraweeController.java    From fresco with MIT License 5 votes vote down vote up
public PipelineDraweeController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    DrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    @Nullable MemoryCache<CacheKey, CloseableImage> memoryCache,
    @Nullable ImmutableList<DrawableFactory> globalDrawableFactories) {
  super(deferredReleaser, uiThreadExecutor, null, null);
  mResources = resources;
  mDefaultDrawableFactory = new DefaultDrawableFactory(resources, animatedDrawableFactory);
  mGlobalDrawableFactories = globalDrawableFactories;
  mMemoryCache = memoryCache;
}
 
Example #15
Source File: AbstractDraweeController.java    From fresco with MIT License 5 votes vote down vote up
public AbstractDraweeController(
    DeferredReleaser deferredReleaser,
    Executor uiThreadImmediateExecutor,
    String id,
    Object callerContext) {
  mDeferredReleaser = deferredReleaser;
  mUiThreadImmediateExecutor = uiThreadImmediateExecutor;
  init(id, callerContext);
}
 
Example #16
Source File: AbstractDraweeControllerTest.java    From fresco with MIT License 5 votes vote down vote up
public FakeDraweeController(
    DeferredReleaser deferredReleaser,
    Executor uiThreadExecutor,
    Supplier<DataSource<FakeImage>> dataSourceSupplier,
    String id,
    Object callerContext) {
  super(deferredReleaser, uiThreadExecutor, id, callerContext);
  mDataSourceSupplier = dataSourceSupplier;
}