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


Java CloseableImage类代码示例

本文整理汇总了Java中com.facebook.imagepipeline.image.CloseableImage的典型用法代码示例。如果您正苦于以下问题:Java CloseableImage类的具体用法?Java CloseableImage怎么用?Java CloseableImage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: newController

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
public PipelineDraweeController newController(
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    CacheKey cacheKey,
    Object callerContext,
    @Nullable ImmutableList<DrawableFactory> customDrawableFactories) {
  Preconditions.checkState(mResources != null, "init() not called");
  // Field values passed as arguments so that any subclass of PipelineDraweeControllerFactory
  // can simply override internalCreateController() and return a custom Drawee controller
  PipelineDraweeController controller = internalCreateController(
      mResources,
      mDeferredReleaser,
      mAnimatedDrawableFactory,
      mUiThreadExecutor,
      mMemoryCache,
      mDrawableFactories,
      customDrawableFactories,
      dataSourceSupplier,
      id,
      cacheKey,
      callerContext);
  if (mDebugOverlayEnabledSupplier != null) {
    controller.setDrawDebugOverlay(mDebugOverlayEnabledSupplier.get());
  }
  return controller;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PipelineDraweeControllerFactory.java

示例2: internalCreateController

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
protected PipelineDraweeController internalCreateController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    DrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    MemoryCache<CacheKey, CloseableImage> memoryCache,
    @Nullable ImmutableList<DrawableFactory> globalDrawableFactories,
    @Nullable ImmutableList<DrawableFactory> customDrawableFactories,
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    CacheKey cacheKey,
    Object callerContext) {
  PipelineDraweeController controller = new PipelineDraweeController(
      resources,
      deferredReleaser,
      animatedDrawableFactory,
      uiThreadExecutor,
      memoryCache,
      dataSourceSupplier,
      id,
      cacheKey,
      callerContext,
      globalDrawableFactories);
  controller.setCustomDrawableFactories(customDrawableFactories);
  return controller;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PipelineDraweeControllerFactory.java

示例3: createDrawable

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
@Override
public Drawable createDrawable(CloseableImage closeableImage) {
  if (closeableImage instanceof CloseableStaticBitmap) {
    CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) closeableImage;
    Drawable bitmapDrawable =
        new BitmapDrawable(mResources, closeableStaticBitmap.getUnderlyingBitmap());
    if (!hasTransformableRotationAngle(closeableStaticBitmap)
        && !hasTransformableExifOrientation(closeableStaticBitmap)) {
      // Return the bitmap drawable directly as there's nothing to transform in it
      return bitmapDrawable;
    } else {
      return new OrientedDrawable(
          bitmapDrawable,
          closeableStaticBitmap.getRotationAngle(),
          closeableStaticBitmap.getExifOrientation());
    }
  } else if (mAnimatedDrawableFactory != null
      && mAnimatedDrawableFactory.supportsImageType(closeableImage)) {
    return mAnimatedDrawableFactory.createDrawable(closeableImage);
  }
  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PipelineDraweeController.java

示例4: PipelineDraweeController

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
public PipelineDraweeController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    DrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    MemoryCache<CacheKey, CloseableImage> memoryCache,
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    CacheKey cacheKey,
    Object callerContext,
    @Nullable ImmutableList<DrawableFactory> globalDrawableFactories) {
  super(deferredReleaser, uiThreadExecutor, id, callerContext);
  mResources = resources;
  mAnimatedDrawableFactory = animatedDrawableFactory;
  mMemoryCache = memoryCache;
  mCacheKey = cacheKey;
  mGlobalDrawableFactories = globalDrawableFactories;
  init(dataSourceSupplier);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:PipelineDraweeController.java

示例5: onFrameRendered

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
@Override
public synchronized void onFrameRendered(
    int frameNumber,
    CloseableReference<Bitmap> bitmapReference,
    @BitmapAnimationBackend.FrameType int frameType) {
  Preconditions.checkNotNull(bitmapReference);

  // Close up prepared references.
  removePreparedReference(frameNumber);

  // Create the new image reference and cache it.
  CloseableReference<CloseableImage> closableReference = null;
  try {
    closableReference = createImageReference(bitmapReference);
    if (closableReference != null) {
      CloseableReference.closeSafely(mLastRenderedItem);
      mLastRenderedItem = mAnimatedFrameCache.cache(frameNumber, closableReference);
    }
  } finally {
    CloseableReference.closeSafely(closableReference);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:FrescoFrameCache.java

示例6: convertToBitmapReferenceAndClose

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
/**
 * Converts the given image reference to a bitmap reference
 * and closes the original image reference.
 *
 * @param closeableImage the image to convert. It will be closed afterwards and will be invalid
 * @return the closeable bitmap reference to be used
 */
@VisibleForTesting
@Nullable
static CloseableReference<Bitmap> convertToBitmapReferenceAndClose(
    final @Nullable CloseableReference<CloseableImage> closeableImage) {
  try {
    if (CloseableReference.isValid(closeableImage) &&
        closeableImage.get() instanceof CloseableStaticBitmap) {

      CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) closeableImage.get();
      if (closeableStaticBitmap != null) {
        // We return a clone of the underlying bitmap reference that has to be manually closed
        // and then close the passed CloseableStaticBitmap in order to preserve correct
        // cache size calculations.
        return closeableStaticBitmap.cloneUnderlyingBitmapReference();
      }
    }
    // Not a bitmap reference, so we return null
    return null;
  } finally {
    CloseableReference.closeSafely(closeableImage);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:FrescoFrameCache.java

示例7: ImagePipeline

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
public ImagePipeline(
    ProducerSequenceFactory producerSequenceFactory,
    Set<RequestListener> requestListeners,
    Supplier<Boolean> isPrefetchEnabledSupplier,
    MemoryCache<CacheKey, CloseableImage> bitmapMemoryCache,
    MemoryCache<CacheKey, PooledByteBuffer> encodedMemoryCache,
    BufferedDiskCache mainBufferedDiskCache,
    BufferedDiskCache smallImageBufferedDiskCache,
    CacheKeyFactory cacheKeyFactory,
    ThreadHandoffProducerQueue threadHandoffProducerQueue,
    Supplier<Boolean> suppressBitmapPrefetchingSupplier) {
  mIdCounter = new AtomicLong();
  mProducerSequenceFactory = producerSequenceFactory;
  mRequestListener = new ForwardingRequestListener(requestListeners);
  mIsPrefetchEnabledSupplier = isPrefetchEnabledSupplier;
  mBitmapMemoryCache = bitmapMemoryCache;
  mEncodedMemoryCache = encodedMemoryCache;
  mMainBufferedDiskCache = mainBufferedDiskCache;
  mSmallImageBufferedDiskCache = smallImageBufferedDiskCache;
  mCacheKeyFactory = cacheKeyFactory;
  mThreadHandoffProducerQueue = threadHandoffProducerQueue;
  mSuppressBitmapPrefetchingSupplier = suppressBitmapPrefetchingSupplier;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:ImagePipeline.java

示例8: getDataFetchSequence

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
/**
 * bitmap cache get ->
 * background thread hand-off -> bitmap cache -> decode -> resize and rotate -> (webp transcode)
 * -> data fetch.
 */
private synchronized Producer<CloseableReference<CloseableImage>> getDataFetchSequence() {
  if (mDataFetchSequence == null) {
    Producer<EncodedImage> inputProducer = mProducerFactory.newDataFetchProducer();
    if (WebpSupportStatus.sIsWebpSupportRequired &&
        (!mWebpSupportEnabled || WebpSupportStatus.sWebpBitmapFactory == null)) {
      inputProducer = mProducerFactory.newWebpTranscodeProducer(inputProducer);
    }
    inputProducer = mProducerFactory.newAddImageTransformMetaDataProducer(inputProducer);
    inputProducer = mProducerFactory.newResizeAndRotateProducer(
        inputProducer,
        true,
        mUseDownsamplingRatio);
    mDataFetchSequence = newBitmapCacheGetToDecodeSequence(inputProducer);
  }
  return mDataFetchSequence;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:ProducerSequenceFactory.java

示例9: testNonStaticBitmapIsPassedOn

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
@Test
public void testNonStaticBitmapIsPassedOn() {
  SingleUsePostprocessorConsumer postprocessorConsumer = produceResults();
  CloseableAnimatedImage sourceCloseableAnimatedImage = mock(CloseableAnimatedImage.class);
  CloseableReference<CloseableImage> sourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(sourceCloseableAnimatedImage);
  postprocessorConsumer.onNewResult(sourceCloseableImageRef, Consumer.IS_LAST);
  sourceCloseableImageRef.close();
  mTestExecutorService.runUntilIdle();

  mInOrder.verify(mConsumer).onNewResult(any(CloseableReference.class), eq(Consumer.IS_LAST));
  mInOrder.verifyNoMoreInteractions();

  assertEquals(1, mResults.size());
  CloseableReference<CloseableImage> res0 = mResults.get(0);
  assertTrue(CloseableReference.isValid(res0));
  assertSame(sourceCloseableAnimatedImage, res0.get());
  res0.close();

  verify(sourceCloseableAnimatedImage).close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:AnimatedSingleUsePostprocessorProducerTest.java

示例10: testNonStaticBitmapIsPassedOn

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
@Test
public void testNonStaticBitmapIsPassedOn() {
  RepeatedPostprocessorConsumer postprocessorConsumer = produceResults();
  RepeatedPostprocessorRunner repeatedPostprocessorRunner = getRunner();

  CloseableAnimatedImage sourceCloseableAnimatedImage = mock(CloseableAnimatedImage.class);
  CloseableReference<CloseableImage> sourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(sourceCloseableAnimatedImage);
  postprocessorConsumer.onNewResult(sourceCloseableImageRef, Consumer.IS_LAST);
  sourceCloseableImageRef.close();
  mTestExecutorService.runUntilIdle();

  mInOrder.verify(mConsumer).onNewResult(any(CloseableReference.class), eq(Consumer.NO_FLAGS));
  mInOrder.verifyNoMoreInteractions();

  assertEquals(1, mResults.size());
  CloseableReference<CloseableImage> res0 = mResults.get(0);
  assertTrue(CloseableReference.isValid(res0));
  assertSame(sourceCloseableAnimatedImage, res0.get());
  res0.close();

  performCancelAndVerifyOnCancellation();
  verify(sourceCloseableAnimatedImage).close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:AnimatedRepeatedPostprocessorProducerTest.java

示例11: verifyNewResultProcessed

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
private void verifyNewResultProcessed(int index, Bitmap destBitmap) {
  mInOrder.verify(mProducerListener).onProducerStart(mRequestId, PostprocessorProducer.NAME);
  mInOrder.verify(mPostprocessor).process(mSourceBitmap, mPlatformBitmapFactory);
  mInOrder.verify(mProducerListener).requiresExtraMap(mRequestId);
  mInOrder.verify(mProducerListener)
      .onProducerFinishWithSuccess(mRequestId, PostprocessorProducer.NAME, mExtraMap);
  mInOrder.verify(mConsumer).onNewResult(any(CloseableReference.class), eq(Consumer.NO_FLAGS));
  mInOrder.verifyNoMoreInteractions();

  assertEquals(index + 1, mResults.size());
  CloseableReference<CloseableImage> res0 = mResults.get(index);
  assertTrue(CloseableReference.isValid(res0));
  assertSame(destBitmap, ((CloseableStaticBitmap) res0.get()).getUnderlyingBitmap());
  res0.close();
  verify(mBitmapResourceReleaser).release(destBitmap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:AnimatedRepeatedPostprocessorProducerTest.java

示例12: testFetchDecodedImage

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
@Test
public void testFetchDecodedImage() {
  Producer<CloseableReference<CloseableImage>> decodedSequence = mock(Producer.class);
  when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
      .thenReturn(decodedSequence);
  DataSource<CloseableReference<CloseableImage>> dataSource =
      mImagePipeline.fetchDecodedImage(mImageRequest, mCallerContext);
  assertFalse(dataSource.isFinished());
  verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
  verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
  ArgumentCaptor<ProducerContext> producerContextArgumentCaptor =
      ArgumentCaptor.forClass(ProducerContext.class);
  verify(decodedSequence)
      .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture());
  assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected());
  assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ImagePipelineTest.java

示例13: createDrawableFromFetchedResult

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
private Drawable createDrawableFromFetchedResult(Context context, CloseableImage image) {
    if (image instanceof CloseableStaticBitmap) {
        CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
        BitmapDrawable bitmapDrawable = createBitmapDrawable(context, closeableStaticBitmap.getUnderlyingBitmap());
        return (closeableStaticBitmap.getRotationAngle() != 0 && closeableStaticBitmap.getRotationAngle() != -1 ? new OrientedDrawable(bitmapDrawable, closeableStaticBitmap.getRotationAngle()) : bitmapDrawable);
    } else if (image instanceof CloseableAnimatedImage) {
        AnimatedDrawableFactory animatedDrawableFactory = Fresco.getImagePipelineFactory().getAnimatedFactory().getAnimatedDrawableFactory(context);
        if (animatedDrawableFactory != null) {
            AnimatedDrawable animatedDrawable = (AnimatedDrawable) animatedDrawableFactory.create(image);
            if (animatedDrawable != null) {
                return animatedDrawable;
            }
        }
    }
    throw new UnsupportedOperationException("Unrecognized image class: " + image);
}
 
开发者ID:Bilibili,项目名称:boxing,代码行数:17,代码来源:BoxingFrescoLoader.java

示例14: getDecodedImageProducerSequence

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
/**
 * Returns a sequence that can be used for a request for a decoded image.
 *
 * @param imageRequest the request that will be submitted
 * @return the sequence that should be used to process the request
 */
public Producer<CloseableReference<CloseableImage>> getDecodedImageProducerSequence(
    ImageRequest imageRequest) {
  Producer<CloseableReference<CloseableImage>> pipelineSequence =
      getBasicDecodedImageSequence(imageRequest);

  if (imageRequest.getPostprocessor() != null) {
    pipelineSequence = getPostprocessorSequence(pipelineSequence);
  }

  if (mUseBitmapPrepareToDraw) {
    pipelineSequence = getBitmapPrepareSequence(pipelineSequence);
  }

  return pipelineSequence;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:ProducerSequenceFactory.java

示例15: testDontCacheIntermediateImageAsAlreadyHaveFullQuality

import com.facebook.imagepipeline.image.CloseableImage; //导入依赖的package包/类
@Test
public void testDontCacheIntermediateImageAsAlreadyHaveFullQuality() {
  setupBitmapMemoryCacheGetNotFound();
  setupInputProducerStreamingSuccess();
  CloseableImage closeableImage = mock(CloseableImage.class);
  when(closeableImage.getQualityInfo()).thenReturn(ImmutableQualityInfo.FULL_QUALITY);
  CloseableReference<CloseableImage> closeableImageRef = CloseableReference.of(closeableImage);
  setupBitmapMemoryCacheGetSuccessOnSecondRead(closeableImageRef);
  mBitmapMemoryCacheProducer.produceResults(mConsumer, mProducerContext);
  verify(mMemoryCache, never()).cache(mBitmapMemoryCacheKey, mIntermediateImageReference);
  verify(mMemoryCache).cache(mBitmapMemoryCacheKey, mFinalImageReference);
  verify(mConsumer).onNewResult(closeableImageRef, Consumer.NO_FLAGS);
  verify(mConsumer).onNewResult(mFinalImageReferenceClone, Consumer.IS_LAST);
  Assert.assertTrue(!mFinalImageReferenceClone.isValid());
  Assert.assertEquals(
      0,
      closeableImageRef.getUnderlyingReferenceTestOnly().getRefCountTestOnly());
  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, never())
      .onUltimateProducerReached(anyString(), anyString(), anyBoolean());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:BitmapMemoryCacheProducerTest.java


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