@Override
  public void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
    if (!dataSource.isFinished()) {
      return;
    }

    CloseableReference<CloseableImage> closeableImageRef = dataSource.getResult();
    CloseableReference<Bitmap> bitmapReference = null;
    if (closeableImageRef != null && closeableImageRef.get() instanceof CloseableStaticBitmap) {
      bitmapReference =
          ((CloseableStaticBitmap) closeableImageRef.get()).cloneUnderlyingBitmapReference();
    }

    try {
      onNewResultImpl(bitmapReference);
    } finally {
      CloseableReference.closeSafely(bitmapReference);
      CloseableReference.closeSafely(closeableImageRef);
    }
  }
Implementation of {@link DataSubscriber} for cases where the client wants access to a bitmap
reference.

<p>Sample usage:

<pre>
<code>
dataSource.subscribe(
  new BaseBitmapReferenceDataSubscriber() {
    {@literal @}Override
    public void onNewResultImpl(@Nullable CloseableReference<Bitmap> bitmapReference) {
      // Pass bitmap to another component, which clones the bitmap reference if it needs to
      // hold on to the bitmap.
      doSomething(bitmapReference);
      // No need to do any cleanup.
    }

    {@literal @}Override
    public void onFailureImpl(DataSource dataSource) {
      // No cleanup required here.
    }
  });
</code>
</pre>
imagepipeline/src/main/java/com/facebook/imagepipeline/datasource/BaseBitmapReferenceDataSubscriber.java