예제 #1
0
 private <T> DataSource<CloseableReference<T>> submitFetchRequest(
     Producer<CloseableReference<T>> producerSequence,
     ImageRequest imageRequest,
     ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit,
     Object callerContext) {
   try {
     ImageRequest.RequestLevel lowestPermittedRequestLevel =
         ImageRequest.RequestLevel.getMax(
             imageRequest.getLowestPermittedRequestLevel(), lowestPermittedRequestLevelOnSubmit);
     SettableProducerContext settableProducerContext =
         new SettableProducerContext(
             imageRequest,
             generateUniqueFutureId(),
             mRequestListener,
             callerContext,
             lowestPermittedRequestLevel,
             /* isPrefetch */ false,
             imageRequest.getProgressiveRenderingEnabled()
                 || !UriUtil.isNetworkUri(imageRequest.getSourceUri()),
             imageRequest.getPriority());
     return CloseableProducerToDataSourceAdapter.create(
         producerSequence, settableProducerContext, mRequestListener);
   } catch (Exception exception) {
     return DataSources.immediateFailedDataSource(exception);
   }
 }
예제 #2
0
 @Override
 public void produceResults(
     final Consumer<CloseableReference<CloseableImage>> consumer, final ProducerContext context) {
   final ImageRequest imageRequest = context.getImageRequest();
   ProgressiveDecoder progressiveDecoder;
   if (!UriUtil.isNetworkUri(imageRequest.getSourceUri())) {
     progressiveDecoder = new LocalImagesProgressiveDecoder(consumer, context);
   } else {
     ProgressiveJpegParser jpegParser = new ProgressiveJpegParser(mByteArrayPool);
     progressiveDecoder =
         new NetworkImagesProgressiveDecoder(
             consumer, context, jpegParser, mProgressiveJpegConfig);
   }
   mNextProducer.produceResults(progressiveDecoder, context);
 }