Ejemplo n.º 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);
   }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
 private static boolean shouldResize(@Nullable Uri uri) {
   // Resizing is inferior to scaling. See http://frescolib.org/docs/resizing-rotating.html#_
   // We resize here only for images likely to be from the device's camera, where the app developer
   // has no control over the original size
   return uri != null && (UriUtil.isLocalContentUri(uri) || UriUtil.isLocalFileUri(uri));
 }