本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}