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


Java ImageRequest.isDiskCacheEnabled方法代码示例

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


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

示例1: produceResults

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
public void produceResults(
    final Consumer<EncodedImage> consumer,
    final ProducerContext producerContext) {
  final ImageRequest imageRequest = producerContext.getImageRequest();
  if (!imageRequest.isDiskCacheEnabled()) {
    maybeStartInputProducer(consumer, producerContext);
    return;
  }

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

  final CacheKey cacheKey =
      mCacheKeyFactory.getEncodedCacheKey(imageRequest, producerContext.getCallerContext());
  final boolean isSmallRequest = (imageRequest.getCacheChoice() == CacheChoice.SMALL);
  final BufferedDiskCache preferredCache = isSmallRequest ?
      mSmallImageBufferedDiskCache : mDefaultBufferedDiskCache;
  final AtomicBoolean isCancelled = new AtomicBoolean(false);
  final Task<EncodedImage> diskLookupTask = preferredCache.get(cacheKey, isCancelled);
  final Continuation<EncodedImage, Void> continuation =
      onFinishDiskReads(consumer, producerContext);
  diskLookupTask.continueWith(continuation);
  subscribeTaskForRequestCancellation(isCancelled, producerContext);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DiskCacheReadProducer.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();
  if (!imageRequest.isDiskCacheEnabled()) {
    mInputProducer.produceResults(consumer, producerContext);
    return;
  }

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

  final Uri uriForPartialCacheKey = createUriForPartialCacheKey(imageRequest);
  final CacheKey partialImageCacheKey = mCacheKeyFactory.getEncodedCacheKey(
      imageRequest,
      uriForPartialCacheKey,
      producerContext.getCallerContext());
  final AtomicBoolean isCancelled = new AtomicBoolean(false);

  final Task<EncodedImage> diskLookupTask =
      mDefaultBufferedDiskCache.get(partialImageCacheKey, isCancelled);
  final Continuation<EncodedImage, Void> continuation =
      onFinishDiskReads(consumer, producerContext, partialImageCacheKey);

  diskLookupTask.continueWith(continuation);
  subscribeTaskForRequestCancellation(isCancelled, producerContext);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PartialDiskCacheProducer.java

示例3: storeResultInDatabase

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
private void storeResultInDatabase(EncodedImage newResult) {
  final ImageRequest imageRequest = mProducerContext.getImageRequest();

  if (!imageRequest.isDiskCacheEnabled() || mMediaId == null) {
    return;
  }

  final ImageRequest.CacheChoice cacheChoice = imageRequest.getCacheChoice() == null
      ? ImageRequest.CacheChoice.DEFAULT
      : imageRequest.getCacheChoice();
  final CacheKey cacheKey =
      mCacheKeyFactory.getEncodedCacheKey(imageRequest, mProducerContext.getCallerContext());

  mMediaVariationsIndex.saveCachedVariant(mMediaId, cacheChoice, cacheKey, newResult);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:MediaVariationsFallbackProducer.java

示例4: 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.isDiskCacheEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。