當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageRequest類代碼示例

本文整理匯總了Java中com.facebook.imagepipeline.request.ImageRequest的典型用法代碼示例。如果您正苦於以下問題:Java ImageRequest類的具體用法?Java ImageRequest怎麽用?Java ImageRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ImageRequest類屬於com.facebook.imagepipeline.request包,在下文中一共展示了ImageRequest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCacheKey

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
private CacheKey getCacheKey() {
  final ImageRequest imageRequest = getImageRequest();
  final CacheKeyFactory cacheKeyFactory = mImagePipeline.getCacheKeyFactory();
  CacheKey cacheKey = null;
  if (cacheKeyFactory != null && imageRequest != null) {
    if (imageRequest.getPostprocessor() != null) {
      cacheKey = cacheKeyFactory.getPostprocessedBitmapCacheKey(
          imageRequest,
          getCallerContext());
    } else {
      cacheKey = cacheKeyFactory.getBitmapCacheKey(
          imageRequest,
          getCallerContext());
    }
  }
  return cacheKey;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:PipelineDraweeControllerBuilder.java

示例2: onRequestFailure

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
@Override
public void onRequestFailure(
    ImageRequest request,
    String requestId,
    Throwable throwable,
    boolean isPrefetch) {
  final int numberOfListeners = mRequestListeners.size();
  for (int i = 0; i < numberOfListeners; ++i) {
    RequestListener listener = mRequestListeners.get(i);
    try {
      listener.onRequestFailure(request, requestId, throwable, isPrefetch);
    } catch (Exception exception) {
      // Don't punish the other listeners if we're given a bad one.
      onException("InternalListener exception in onRequestFailure", exception);
    }
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:ForwardingRequestListener.java

示例3: onRequestFailure

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
@Override
public synchronized void onRequestFailure(
    ImageRequest request,
    String requestId,
    Throwable throwable,
    boolean isPrefetch) {
  if (FLog.isLoggable(FLog.WARN)) {
    Long startTime = mRequestStartTimeMap.remove(requestId);
    long currentTime = getTime();
    FLog.w(
        TAG,
        "time %d: onRequestFailure: {requestId: %s, elapsedTime: %d ms, throwable: %s}",
        currentTime,
        requestId,
        getElapsedTime(startTime, currentTime),
        throwable.toString());
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:RequestLoggingListener.java

示例4: setUp

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mBitmapMemoryCacheGetProducer =
      new BitmapMemoryCacheGetProducer(mMemoryCache, mCacheKeyFactory, mInputProducer);
  mCloseableImage1 = mock(CloseableImage.class);
  mFinalImageReference = CloseableReference.of(mCloseableImage1);
  when(mCloseableImage1.getQualityInfo()).thenReturn(ImmutableQualityInfo.FULL_QUALITY);

  when(mProducerContext.getImageRequest()).thenReturn(mImageRequest);
  when(mProducerContext.getListener()).thenReturn(mProducerListener);
  when(mProducerContext.getId()).thenReturn(mRequestId);
  when(mProducerListener.requiresExtraMap(mRequestId)).thenReturn(true);
  when(mProducerContext.getLowestPermittedRequestLevel())
      .thenReturn(ImageRequest.RequestLevel.FULL_FETCH);
  when(mProducerContext.getCallerContext())
      .thenReturn(PRODUCER_NAME);
  when(mCacheKeyFactory.getBitmapCacheKey(mImageRequest, PRODUCER_NAME)).thenReturn(mCacheKey);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:BitmapMemoryCacheGetProducerTest.java

示例5: testGetBitmapCacheGetSupplier

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
@Test
public void testGetBitmapCacheGetSupplier() {
  Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier =
      mImagePipeline.getDataSourceSupplier(
          mImageRequest,
          mCallerContext,
          ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE);
  Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(bitmapCacheSequence);
  dataSourceSupplier.get();
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0",  false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(bitmapCacheSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:ImagePipelineTest.java

示例6: testSmallImageDiskCacheGetNotFoundInputProducerSuccess

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
@Test
public void testSmallImageDiskCacheGetNotFoundInputProducerSuccess() {
  when(mImageRequest.getCacheChoice()).thenReturn(ImageRequest.CacheChoice.SMALL);
  setupDiskCacheGetNotFound(mSmallImageBufferedDiskCache);
  setupInputProducerSuccess();
  mDiskCacheReadProducer.produceResults(mConsumer, mProducerContext);
  verify(mConsumer).onNewResult(mFinalEncodedImage, Consumer.IS_LAST);
  verify(mProducerListener).onProducerStart(mRequestId, PRODUCER_NAME);
  ArgumentCaptor<HashMap> captor = ArgumentCaptor.forClass(HashMap.class);
  verify(mProducerListener).onProducerFinishWithSuccess(
      eq(mRequestId), eq(PRODUCER_NAME), captor.capture());
  Map<String, String> resultMap = captor.getValue();
  assertEquals("false", resultMap.get(DiskCacheReadProducer.EXTRA_CACHED_VALUE_FOUND));
  assertNull(resultMap.get(DiskCacheReadProducer.ENCODED_IMAGE_SIZE));
  verify(mProducerListener, never())
      .onUltimateProducerReached(anyString(), anyString(), anyBoolean());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:DiskCacheReadProducerTest.java

示例7: getLength

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
private int getLength(ImageRequest imageRequest) {
  AssetFileDescriptor fd = null;
  try {
    fd = mResources.openRawResourceFd(getResourceId(imageRequest));
    return (int) fd.getLength();
  } catch (Resources.NotFoundException e) {
    return -1;
  } finally {
    try {
      if (fd != null) {
        fd.close();
      }
    } catch (IOException ignored) {
      // There's nothing we can do with the exception when closing descriptor.
    }
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:LocalResourceFetchProducer.java

示例8: setUp

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  mExecutor = new TestExecutorService(new FakeClock());
  mQualifiedResourceFetchProducer = new QualifiedResourceFetchProducer(
      mExecutor,
      mPooledByteBufferFactory,
      mContentResolver);
  mContentUri = UriUtil.getUriForQualifiedResource(PACKAGE_NAME, RESOURCE_ID);

  mProducerContext = new SettableProducerContext(
      mImageRequest,
      REQUEST_ID,
      mProducerListener,
      CALLER_CONTEXT,
      ImageRequest.RequestLevel.FULL_FETCH,
      false,
      true,
      Priority.MEDIUM);
  when(mImageRequest.getSourceUri()).thenReturn(mContentUri);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:QualifiedResourceFetchProducerTest.java

示例9: setUp

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  PowerMockito.mockStatic(UriUtil.class, MediaUtils.class);

  ProducerFactory producerFactory = mock(ProducerFactory.class, RETURNS_MOCKS);

  mProducerSequenceFactory = new ProducerSequenceFactory(
      RuntimeEnvironment.application.getContentResolver(),
      producerFactory,
      null,
      true,
      false,
      null,
      false,
      false,
      false);

  when(mImageRequest.getLowestPermittedRequestLevel())
      .thenReturn(ImageRequest.RequestLevel.FULL_FETCH);
  mUri = Uri.parse("http://dummy");
  when(mImageRequest.getSourceUri()).thenReturn(mUri);
  when(MediaUtils.extractMime(mUri.getPath())).thenReturn(mDummyMime);
  when(MediaUtils.isVideo(mDummyMime)).thenReturn(false);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:ProducerSequenceFactoryTest.java

示例10: SettableProducerContext

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
public SettableProducerContext(
    ImageRequest imageRequest,
    String id,
    ProducerListener producerListener,
    Object callerContext,
    ImageRequest.RequestLevel lowestPermittedRequestLevel,
    boolean isPrefetch,
    boolean isIntermediateResultExpected,
    Priority priority) {
  super(
      imageRequest,
      id,
      producerListener,
      callerContext,
      lowestPermittedRequestLevel,
      isPrefetch,
      isIntermediateResultExpected,
      priority);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:SettableProducerContext.java

示例11: onNewResultImpl

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
@Override
protected void onNewResultImpl(EncodedImage newResult, @Status int status) {
  ImageRequest request = mProducerContext.getImageRequest();
  boolean isLast = isLast(status);
  boolean isGoodEnough =
      ThumbnailSizeChecker.isImageBigEnough(newResult, request.getResizeOptions());
  if (newResult != null && (isGoodEnough || request.getLocalThumbnailPreviewsEnabled())) {
    if (isLast && isGoodEnough) {
      getConsumer().onNewResult(newResult, status);
    } else {
      int alteredStatus = turnOffStatusFlag(status, IS_LAST);
      getConsumer().onNewResult(newResult, alteredStatus);
    }
  }
  if (isLast && !isGoodEnough) {
    EncodedImage.closeSafely(newResult);

    mInputProducer2.produceResults(getConsumer(), mProducerContext);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:BranchOnSeparateImagesProducer.java

示例12: testBitmapMemoryCacheGetIntermediateImageLowestLevelReached

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
@Test
public void testBitmapMemoryCacheGetIntermediateImageLowestLevelReached() {
  setupBitmapMemoryCacheGetIntermediateImage();
  when(mProducerContext.getLowestPermittedRequestLevel())
      .thenReturn(ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE);
  mBitmapMemoryCacheProducer.produceResults(mConsumer, mProducerContext);
  verify(mConsumer).onNewResult(mIntermediateImageReference, Consumer.NO_FLAGS);
  verify(mConsumer).onNewResult(null, Consumer.IS_LAST);
  verify(mProducerListener).onProducerStart(mRequestId, PRODUCER_NAME);
  Map<String, String> extraMap =
      ImmutableMap.of(BitmapMemoryCacheProducer.EXTRA_CACHED_VALUE_FOUND, "false");
  verify(mProducerListener).onProducerFinishWithSuccess(mRequestId, PRODUCER_NAME, extraMap);
  verify(mProducerListener).onUltimateProducerReached(mRequestId, PRODUCER_NAME, false);
  Assert.assertTrue(!mIntermediateImageReference.isValid());
  verifyNoMoreInteractions(mInputProducer);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:BitmapMemoryCacheProducerTest.java

示例13: 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

示例14: testFetchFromBitmapCacheDueToImageRequest

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
@Test
public void testFetchFromBitmapCacheDueToImageRequest() {
  Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class);
  when(mImageRequest.getLowestPermittedRequestLevel())
      .thenReturn(ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(bitmapCacheSequence);
  mImagePipeline.fetchDecodedImage(mImageRequest, mCallerContext);
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0",  false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(bitmapCacheSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
  assertEquals(
      producerContextArgumentCaptor.getValue().getLowestPermittedRequestLevel(),
      ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:ImagePipelineTest.java

示例15: loadThumb

import com.facebook.imagepipeline.request.ImageRequest; //導入依賴的package包/類
private void loadThumb(
    SimpleDraweeView draweeView,
    Size size,
    ImageRequest.RequestLevel requestLevel) {
  ImageRequest request = ImageRequestBuilder.newBuilderWithSource(size.uri)
      .setMediaVariations(MediaVariations.newBuilderForMediaId(MEDIA_ID)
          .setForceRequestForSpecifiedUri(true)
          .build())
      .setLowestPermittedRequestLevel(requestLevel)
      .setResizeOptions(new ResizeOptions(draweeView.getWidth(), draweeView.getHeight()))
      .setCacheChoice(size.cacheChoice)
      .build();
  DraweeController controller = Fresco.newDraweeControllerBuilder()
      .setImageRequest(request)
      .setOldController(draweeView.getController())
      .build();
  draweeView.setController(controller);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:MediaVariationsFragment.java


注:本文中的com.facebook.imagepipeline.request.ImageRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。