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

    CloseableReference<CloseableImage> closeableImageRef = dataSource.getResult();
    Bitmap bitmap = null;
    if (closeableImageRef != null && closeableImageRef.get() instanceof CloseableBitmap) {
      bitmap = ((CloseableBitmap) closeableImageRef.get()).getUnderlyingBitmap();
    }

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

<p>Sample usage:

<pre>
<code>
dataSource.subscribe(
  new BaseBitmapDataSubscriber() {
    {@literal @}Override
    public void onNewResultImpl(@Nullable Bitmap bitmap) {
      // Pass bitmap to system, which makes a copy of the bitmap.
      updateStatus(bitmap);
      // 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/BaseBitmapDataSubscriber.java