当前位置: 首页>>代码示例>>Java>>正文


Java ImageRequest.getMediaVariations方法代码示例

本文整理汇总了Java中com.facebook.imagepipeline.request.ImageRequest.getMediaVariations方法的典型用法代码示例。如果您正苦于以下问题:Java ImageRequest.getMediaVariations方法的具体用法?Java ImageRequest.getMediaVariations怎么用?Java ImageRequest.getMediaVariations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.imagepipeline.request.ImageRequest的用法示例。


在下文中一共展示了ImageRequest.getMediaVariations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: submitFetchRequest

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
private <T> DataSource<CloseableReference<T>> submitFetchRequest(
    Producer<CloseableReference<T>> producerSequence,
    ImageRequest imageRequest,
    ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit,
    Object callerContext) {
  final RequestListener requestListener = getRequestListenerForRequest(imageRequest);

  try {
    ImageRequest.RequestLevel lowestPermittedRequestLevel =
        ImageRequest.RequestLevel.getMax(
            imageRequest.getLowestPermittedRequestLevel(),
            lowestPermittedRequestLevelOnSubmit);
    SettableProducerContext settableProducerContext = new SettableProducerContext(
        imageRequest,
        generateUniqueFutureId(),
        requestListener,
        callerContext,
        lowestPermittedRequestLevel,
      /* isPrefetch */ false,
        imageRequest.getProgressiveRenderingEnabled() ||
            imageRequest.getMediaVariations() != null ||
            !UriUtil.isNetworkUri(imageRequest.getSourceUri()),
        imageRequest.getPriority());
    return CloseableProducerToDataSourceAdapter.create(
        producerSequence,
        settableProducerContext,
        requestListener);
  } catch (Exception exception) {
    return DataSources.immediateFailedDataSource(exception);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:ImagePipeline.java

示例2: produceResults

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
public void produceResults(
    final Consumer<EncodedImage> consumer,
    final ProducerContext producerContext) {
  final ImageRequest imageRequest = producerContext.getImageRequest();
  final ResizeOptions resizeOptions = imageRequest.getResizeOptions();
  final MediaVariations mediaVariations = imageRequest.getMediaVariations();

  if (!imageRequest.isDiskCacheEnabled() ||
      resizeOptions == null ||
      resizeOptions.height <= 0 ||
      resizeOptions.width <= 0 ||
      imageRequest.getBytesRange() != null) {
    startInputProducerWithExistingConsumer(consumer, producerContext);
    return;
  }

  if (mediaVariations == null) {
    startInputProducerWithExistingConsumer(consumer, producerContext);
    return;
  }

  producerContext.getListener().onProducerStart(producerContext.getId(), PRODUCER_NAME);

  final AtomicBoolean isCancelled = new AtomicBoolean(false);

  if (mediaVariations.getVariantsCount() > 0) {
    chooseFromVariants(
        consumer,
        producerContext,
        imageRequest,
        mediaVariations,
        resizeOptions,
        isCancelled);
  } else {
    MediaVariations.Builder mediaVariationsBuilder =
        MediaVariations.newBuilderForMediaId(mediaVariations.getMediaId())
            .setForceRequestForSpecifiedUri(mediaVariations.shouldForceRequestForSpecifiedUri())
            .setSource(MediaVariations.SOURCE_INDEX_DB);
    Task<MediaVariations> indexedMediaVariationsTask =
        mMediaVariationsIndex.getCachedVariants(
            mediaVariations.getMediaId(), mediaVariationsBuilder);
    indexedMediaVariationsTask.continueWith(
        new Continuation<MediaVariations, Object>() {

          @Override
          public Object then(Task<MediaVariations> task) throws Exception {
            if (task.isCancelled() || task.isFaulted()) {
              return task;
            } else {
              try {
                if (task.getResult() == null) {
                  startInputProducerWithWrappedConsumer(
                      consumer, producerContext, mediaVariations.getMediaId());
                  return null;
                } else {
                  return chooseFromVariants(
                      consumer,
                      producerContext,
                      imageRequest,
                      task.getResult(),
                      resizeOptions,
                      isCancelled);
                }
              } catch (Exception e) {
                return null;
              }
            }
          }
        });
  }

  subscribeTaskForRequestCancellation(isCancelled, producerContext);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:74,代码来源:MediaVariationsFallbackProducer.java


注:本文中的com.facebook.imagepipeline.request.ImageRequest.getMediaVariations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。