@Override
    public void onNewResultImpl(@Nullable EncodedImage newResult, @Status int status) {
      mProducerContext.getProducerListener().onProducerStart(mProducerContext, PRODUCER_NAME);
      // intermediate, null or uncacheable results are not cached, so we just forward them
      // as well as the images with unknown format which could be html response from the server
      if (isNotLast(status)
          || newResult == null
          || statusHasAnyFlag(status, DO_NOT_CACHE_ENCODED | IS_PARTIAL_RESULT)
          || newResult.getImageFormat() == ImageFormat.UNKNOWN) {
        mProducerContext
            .getProducerListener()
            .onProducerFinishWithSuccess(mProducerContext, PRODUCER_NAME, null);
        getConsumer().onNewResult(newResult, status);
        return;
      }

      final ImageRequest imageRequest = mProducerContext.getImageRequest();
      final CacheKey cacheKey =
          mCacheKeyFactory.getEncodedCacheKey(imageRequest, mProducerContext.getCallerContext());
      final DiskCachesStore diskCachesStore = mDiskCachesStoreSupplier.get();
      BufferedDiskCache bufferedDiskCache =
          DiskCacheDecision.chooseDiskCacheForRequest(
              imageRequest,
              diskCachesStore.getSmallImageBufferedDiskCache(),
              diskCachesStore.getMainBufferedDiskCache(),
              diskCachesStore.getDynamicBufferedDiskCaches());
      if (bufferedDiskCache == null) {
        mProducerContext
            .getProducerListener()
            .onProducerFinishWithFailure(
                mProducerContext,
                PRODUCER_NAME,
                new DiskCacheDecision.DiskCacheDecisionNoDiskCacheChosenException(
                    "Got no disk cache for CacheChoice: "
                        + Integer.valueOf(imageRequest.getCacheChoice().ordinal()).toString()),
                null);
        getConsumer().onNewResult(newResult, status);
        return;
      }
      bufferedDiskCache.put(cacheKey, newResult);
      mProducerContext
          .getProducerListener()
          .onProducerFinishWithSuccess(mProducerContext, PRODUCER_NAME, null);

      getConsumer().onNewResult(newResult, status);
    }
Consumer that consumes results from next producer in the sequence.

<p>The consumer puts the last result received into disk cache, and passes all results (success
or failure) down to the next consumer.
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/DiskCacheWriteProducer.java