当前位置: 首页>>代码示例>>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;未经允许,请勿转载。