當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。