com.facebook.imagepipeline.animated.base.AnimatedImageResult Java Examples

The following examples show how to use com.facebook.imagepipeline.animated.base.AnimatedImageResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnimatedImageFactoryGifImplTest.java    From fresco with MIT License 6 votes vote down vote up
private void testCreateDefaults(GifImage mockGifImage, PooledByteBuffer byteBuffer) {
  EncodedImage encodedImage =
      new EncodedImage(CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
  encodedImage.setImageFormat(ImageFormat.UNKNOWN);

  CloseableAnimatedImage closeableImage =
      (CloseableAnimatedImage)
          mAnimatedImageFactory.decodeGif(
              encodedImage, ImageDecodeOptions.defaults(), DEFAULT_BITMAP_CONFIG);

  // Verify we got the right result
  AnimatedImageResult imageResult = closeableImage.getImageResult();
  assertSame(mockGifImage, imageResult.getImage());
  assertNull(imageResult.getPreviewBitmap());
  assertFalse(imageResult.hasDecodedFrame(0));

  // Should not have interacted with these.
  verifyZeroInteractions(mMockAnimatedDrawableBackendProvider);
  verifyZeroInteractions(mMockBitmapFactory);
}
 
Example #2
Source File: AnimatedDrawableBackendImpl.java    From fresco with MIT License 6 votes vote down vote up
public AnimatedDrawableBackendImpl(
    AnimatedDrawableUtil animatedDrawableUtil,
    AnimatedImageResult animatedImageResult,
    Rect bounds,
    boolean downscaleFrameToDrawableDimensions) {
  mAnimatedDrawableUtil = animatedDrawableUtil;
  mAnimatedImageResult = animatedImageResult;
  mAnimatedImage = animatedImageResult.getImage();
  mFrameDurationsMs = mAnimatedImage.getFrameDurations();
  mAnimatedDrawableUtil.fixFrameDurations(mFrameDurationsMs);
  mDurationMs = mAnimatedDrawableUtil.getTotalDurationFromFrameDurations(mFrameDurationsMs);
  mFrameTimestampsMs = mAnimatedDrawableUtil.getFrameTimeStampsFromDurations(mFrameDurationsMs);
  mRenderedBounds = getBoundsToUse(mAnimatedImage, bounds);
  mDownscaleFrameToDrawableDimensions = downscaleFrameToDrawableDimensions;
  mFrameInfos = new AnimatedDrawableFrameInfo[mAnimatedImage.getFrameCount()];
  for (int i = 0; i < mAnimatedImage.getFrameCount(); i++) {
    mFrameInfos[i] = mAnimatedImage.getFrameInfo(i);
  }
}
 
Example #3
Source File: AnimatedImageFactory.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
private CloseableImage getCloseableImage(ImageDecodeOptions options, AnimatedImage image) {
  int frameForPreview = options.useLastFrameForPreview ? image.getFrameCount() - 1 : 0;
  CloseableReference<Bitmap> previewBitmap = null;
  if (options.decodePreviewFrame) {
    previewBitmap = createPreviewBitmap(image, frameForPreview);
  }
  try {
    AnimatedImageResult animatedImageResult = AnimatedImageResult.newBuilder(image)
        .setPreviewBitmap(previewBitmap)
        .setFrameForPreview(frameForPreview)
        .build();
    return new CloseableAnimatedImage(animatedImageResult);
  } finally {
    CloseableReference.closeSafely(previewBitmap);
  }
}
 
Example #4
Source File: AnimatedDrawableBackendImpl.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
public AnimatedDrawableBackendImpl(
    AnimatedDrawableUtil animatedDrawableUtil,
    AnimatedImageResult animatedImageResult,
    Rect bounds) {
  mAnimatedDrawableUtil = animatedDrawableUtil;
  mAnimatedImageResult = animatedImageResult;
  mAnimatedImage = animatedImageResult.getImage();
  mFrameDurationsMs = mAnimatedImage.getFrameDurations();
  mAnimatedDrawableUtil.fixFrameDurations(mFrameDurationsMs);
  mDurationMs = mAnimatedDrawableUtil.getTotalDurationFromFrameDurations(mFrameDurationsMs);
  mFrameTimestampsMs = mAnimatedDrawableUtil.getFrameTimeStampsFromDurations(mFrameDurationsMs);
  mRenderedBounds = getBoundsToUse(mAnimatedImage, bounds);
  mFrameInfos = new AnimatedDrawableFrameInfo[mAnimatedImage.getFrameCount()];
  for (int i = 0; i < mAnimatedImage.getFrameCount(); i++) {
    mFrameInfos[i] = mAnimatedImage.getFrameInfo(i);
  }
}
 
Example #5
Source File: AnimatedFactoryV2Impl.java    From fresco with MIT License 6 votes vote down vote up
private AnimatedDrawableBackendProvider getAnimatedDrawableBackendProvider() {
  if (mAnimatedDrawableBackendProvider == null) {
    mAnimatedDrawableBackendProvider =
        new AnimatedDrawableBackendProvider() {
          @Override
          public AnimatedDrawableBackend get(
              AnimatedImageResult animatedImageResult, Rect bounds) {
            return new AnimatedDrawableBackendImpl(
                getAnimatedDrawableUtil(),
                animatedImageResult,
                bounds,
                mDownscaleFrameToDrawableDimensions);
          }
        };
  }
  return mAnimatedDrawableBackendProvider;
}
 
Example #6
Source File: AnimatedImageFactoryWebPImplTest.java    From fresco with MIT License 6 votes vote down vote up
private void testCreateDefaults(WebPImage mockWebPImage, PooledByteBuffer byteBuffer) {
  EncodedImage encodedImage =
      new EncodedImage(CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
  encodedImage.setImageFormat(ImageFormat.UNKNOWN);

  CloseableAnimatedImage closeableImage =
      (CloseableAnimatedImage)
          mAnimatedImageFactory.decodeWebP(
              encodedImage, ImageDecodeOptions.defaults(), DEFAULT_BITMAP_CONFIG);

  // Verify we got the right result
  AnimatedImageResult imageResult = closeableImage.getImageResult();
  assertSame(mockWebPImage, imageResult.getImage());
  assertNull(imageResult.getPreviewBitmap());
  assertFalse(imageResult.hasDecodedFrame(0));

  // Should not have interacted with these.
  verifyZeroInteractions(mMockAnimatedDrawableBackendProvider);
  verifyZeroInteractions(mMockBitmapFactory);
}
 
Example #7
Source File: ExperimentalBitmapAnimationDrawableFactory.java    From fresco with MIT License 5 votes vote down vote up
private AnimationBackend createAnimationBackend(AnimatedImageResult animatedImageResult) {
  AnimatedDrawableBackend animatedDrawableBackend =
      createAnimatedDrawableBackend(animatedImageResult);

  BitmapFrameCache bitmapFrameCache = createBitmapFrameCache(animatedImageResult);
  BitmapFrameRenderer bitmapFrameRenderer =
      new AnimatedDrawableBackendFrameRenderer(bitmapFrameCache, animatedDrawableBackend);

  int numberOfFramesToPrefetch = mNumberOfFramesToPrepareSupplier.get();
  BitmapFramePreparationStrategy bitmapFramePreparationStrategy = null;
  BitmapFramePreparer bitmapFramePreparer = null;
  if (numberOfFramesToPrefetch > 0) {
    bitmapFramePreparationStrategy =
        new FixedNumberBitmapFramePreparationStrategy(numberOfFramesToPrefetch);
    bitmapFramePreparer = createBitmapFramePreparer(bitmapFrameRenderer);
  }

  BitmapAnimationBackend bitmapAnimationBackend =
      new BitmapAnimationBackend(
          mPlatformBitmapFactory,
          bitmapFrameCache,
          new AnimatedDrawableBackendAnimationInformation(animatedDrawableBackend),
          bitmapFrameRenderer,
          bitmapFramePreparationStrategy,
          bitmapFramePreparer);

  return AnimationBackendDelegateWithInactivityCheck.createForBackend(
      bitmapAnimationBackend, mMonotonicClock, mScheduledExecutorServiceForUiThread);
}
 
Example #8
Source File: AnimatedImageFactoryImpl.java    From fresco with MIT License 5 votes vote down vote up
private CloseableImage getCloseableImage(
    ImageDecodeOptions options, AnimatedImage image, Bitmap.Config bitmapConfig) {
  List<CloseableReference<Bitmap>> decodedFrames = null;
  CloseableReference<Bitmap> previewBitmap = null;
  try {
    final int frameForPreview = options.useLastFrameForPreview ? image.getFrameCount() - 1 : 0;
    if (options.forceStaticImage) {
      return new CloseableStaticBitmap(
          createPreviewBitmap(image, bitmapConfig, frameForPreview),
          ImmutableQualityInfo.FULL_QUALITY,
          0);
    }

    if (options.decodeAllFrames) {
      decodedFrames = decodeAllFrames(image, bitmapConfig);
      previewBitmap = CloseableReference.cloneOrNull(decodedFrames.get(frameForPreview));
    }

    if (options.decodePreviewFrame && previewBitmap == null) {
      previewBitmap = createPreviewBitmap(image, bitmapConfig, frameForPreview);
    }
    AnimatedImageResult animatedImageResult =
        AnimatedImageResult.newBuilder(image)
            .setPreviewBitmap(previewBitmap)
            .setFrameForPreview(frameForPreview)
            .setDecodedFrames(decodedFrames)
            .setBitmapTransformation(options.bitmapTransformation)
            .build();
    return new CloseableAnimatedImage(animatedImageResult);
  } finally {
    CloseableReference.closeSafely(previewBitmap);
    CloseableReference.closeSafely(decodedFrames);
  }
}
 
Example #9
Source File: AnimatedImageCompositor.java    From fresco with MIT License 5 votes vote down vote up
private void maybeApplyTransformation(Bitmap bitmap) {
  AnimatedImageResult animatedImageResult = mAnimatedDrawableBackend.getAnimatedImageResult();

  if (animatedImageResult == null) {
    return;
  }

  BitmapTransformation tr = animatedImageResult.getBitmapTransformation();

  if (tr == null) {
    return;
  }

  tr.transform(bitmap);
}
 
Example #10
Source File: CloseableAnimatedImage.java    From fresco with MIT License 5 votes vote down vote up
@Override
public void close() {
  AnimatedImageResult imageResult;
  synchronized (this) {
    if (mImageResult == null) {
      return;
    }
    imageResult = mImageResult;
    mImageResult = null;
  }
  imageResult.dispose();
}
 
Example #11
Source File: AnimatedFactoryV2Impl.java    From fresco with MIT License 5 votes vote down vote up
private AnimatedImageFactory buildAnimatedImageFactory() {
  AnimatedDrawableBackendProvider animatedDrawableBackendProvider =
      new AnimatedDrawableBackendProvider() {
        @Override
        public AnimatedDrawableBackend get(AnimatedImageResult imageResult, Rect bounds) {
          return new AnimatedDrawableBackendImpl(
              getAnimatedDrawableUtil(),
              imageResult,
              bounds,
              mDownscaleFrameToDrawableDimensions);
        }
      };
  return new AnimatedImageFactoryImpl(animatedDrawableBackendProvider, mPlatformBitmapFactory);
}
 
Example #12
Source File: ExperimentalBitmapAnimationDrawableFactory.java    From fresco with MIT License 5 votes vote down vote up
private BitmapFrameCache createBitmapFrameCache(AnimatedImageResult animatedImageResult) {
  switch (mCachingStrategySupplier.get()) {
    case CACHING_STRATEGY_FRESCO_CACHE:
      return new FrescoFrameCache(createAnimatedFrameCache(animatedImageResult), true);
    case CACHING_STRATEGY_FRESCO_CACHE_NO_REUSING:
      return new FrescoFrameCache(createAnimatedFrameCache(animatedImageResult), false);
    case CACHING_STRATEGY_KEEP_LAST_CACHE:
      return new KeepLastFrameCache();
    case CACHING_STRATEGY_NO_CACHE:
    default:
      return new NoOpCache();
  }
}
 
Example #13
Source File: AnimatedImageFactoryWebPImplTest.java    From fresco with MIT License 5 votes vote down vote up
private void testCreateWithPreviewBitmap(
    WebPImage mockWebPImage, PooledByteBuffer byteBuffer, Bitmap mockBitmap) throws Exception {
  // For decoding preview frame, expect some calls.
  final AnimatedDrawableBackend mockAnimatedDrawableBackend =
      createAnimatedDrawableBackendMock(1);

  when(mMockAnimatedDrawableBackendProvider.get(
          any(AnimatedImageResult.class), isNull(Rect.class)))
      .thenReturn(mockAnimatedDrawableBackend);
  when(mMockBitmapFactory.createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG))
      .thenReturn(CloseableReference.of(mockBitmap, FAKE_BITMAP_RESOURCE_RELEASER));
  AnimatedImageCompositor mockCompositor = mock(AnimatedImageCompositor.class);
  PowerMockito.whenNew(AnimatedImageCompositor.class)
      .withAnyArguments()
      .thenReturn(mockCompositor);

  ImageDecodeOptions imageDecodeOptions =
      ImageDecodeOptions.newBuilder().setDecodePreviewFrame(true).build();
  EncodedImage encodedImage =
      new EncodedImage(CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
  encodedImage.setImageFormat(ImageFormat.UNKNOWN);
  CloseableAnimatedImage closeableImage =
      (CloseableAnimatedImage)
          mAnimatedImageFactory.decodeWebP(
              encodedImage, imageDecodeOptions, DEFAULT_BITMAP_CONFIG);

  // Verify we got the right result
  AnimatedImageResult imageResult = closeableImage.getImageResult();
  assertSame(mockWebPImage, imageResult.getImage());
  assertNotNull(imageResult.getPreviewBitmap());
  assertFalse(imageResult.hasDecodedFrame(0));

  // Should not have interacted with these.
  verify(mMockAnimatedDrawableBackendProvider)
      .get(any(AnimatedImageResult.class), isNull(Rect.class));
  verifyNoMoreInteractions(mMockAnimatedDrawableBackendProvider);
  verify(mMockBitmapFactory).createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG);
  verifyNoMoreInteractions(mMockBitmapFactory);
  verify(mockCompositor).renderFrame(0, mockBitmap);
}
 
Example #14
Source File: AnimatedDrawableFactory.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an {@link AnimatedDrawable} based on an {@link AnimatedImage}.
 *
 * @param animatedImageResult the result of the code
 * @param options additional options
 * @return a newly constructed {@link AnimatedDrawable}
 */
public AnimatedDrawable create(
    AnimatedImageResult animatedImageResult,
    AnimatedDrawableOptions options) {
  AnimatedImage animatedImage = animatedImageResult.getImage();
  Rect initialBounds = new Rect(0, 0, animatedImage.getWidth(), animatedImage.getHeight());
  AnimatedDrawableBackend animatedDrawableBackend =
      mAnimatedDrawableBackendProvider.get(animatedImageResult, initialBounds);
  return createAnimatedDrawable(options, animatedDrawableBackend);
}
 
Example #15
Source File: AnimatedImageFactoryGifImplTest.java    From fresco with MIT License 5 votes vote down vote up
private void testCreateWithPreviewBitmap(
    GifImage mockGifImage, Bitmap mockBitmap, PooledByteBuffer byteBuffer) throws Exception {
  // For decoding preview frame, expect some calls.
  final AnimatedDrawableBackend mockAnimatedDrawableBackend =
      createAnimatedDrawableBackendMock(1);
  when(mMockAnimatedDrawableBackendProvider.get(
          any(AnimatedImageResult.class), isNull(Rect.class)))
      .thenReturn(mockAnimatedDrawableBackend);
  when(mMockBitmapFactory.createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG))
      .thenReturn(CloseableReference.of(mockBitmap, FAKE_BITMAP_RESOURCE_RELEASER));
  AnimatedImageCompositor mockCompositor = mock(AnimatedImageCompositor.class);
  PowerMockito.whenNew(AnimatedImageCompositor.class)
      .withAnyArguments()
      .thenReturn(mockCompositor);

  ImageDecodeOptions imageDecodeOptions =
      ImageDecodeOptions.newBuilder().setDecodePreviewFrame(true).build();
  EncodedImage encodedImage =
      new EncodedImage(CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
  encodedImage.setImageFormat(ImageFormat.UNKNOWN);
  CloseableAnimatedImage closeableImage =
      (CloseableAnimatedImage)
          mAnimatedImageFactory.decodeGif(
              encodedImage, imageDecodeOptions, DEFAULT_BITMAP_CONFIG);

  // Verify we got the right result
  AnimatedImageResult imageResult = closeableImage.getImageResult();
  assertSame(mockGifImage, imageResult.getImage());
  assertNotNull(imageResult.getPreviewBitmap());
  assertFalse(imageResult.hasDecodedFrame(0));

  // Should not have interacted with these.
  verify(mMockAnimatedDrawableBackendProvider)
      .get(any(AnimatedImageResult.class), isNull(Rect.class));
  verifyNoMoreInteractions(mMockAnimatedDrawableBackendProvider);
  verify(mMockBitmapFactory).createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG);
  verifyNoMoreInteractions(mMockBitmapFactory);
  verify(mockCompositor).renderFrame(0, mockBitmap);
}
 
Example #16
Source File: CloseableAnimatedImage.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void close() {
  AnimatedImageResult imageResult;
  synchronized (this) {
    if (mImageResult == null) {
      return;
    }
    imageResult = mImageResult;
    mImageResult = null;
  }
  imageResult.dispose();
}
 
Example #17
Source File: AnimatedImageFactoryGifImplTest.java    From fresco with MIT License 4 votes vote down vote up
private void testCreateWithDecodeAlFrames(
    GifImage mockGifImage, Bitmap mockBitmap1, Bitmap mockBitmap2, PooledByteBuffer byteBuffer)
    throws Exception {
  // For decoding preview frame, expect some calls.
  final AnimatedDrawableBackend mockAnimatedDrawableBackend =
      createAnimatedDrawableBackendMock(2);

  when(mMockAnimatedDrawableBackendProvider.get(
          any(AnimatedImageResult.class), isNull(Rect.class)))
      .thenReturn(mockAnimatedDrawableBackend);

  when(mMockBitmapFactory.createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG))
      .thenReturn(CloseableReference.of(mockBitmap1, FAKE_BITMAP_RESOURCE_RELEASER))
      .thenReturn(CloseableReference.of(mockBitmap2, FAKE_BITMAP_RESOURCE_RELEASER));
  AnimatedImageCompositor mockCompositor = mock(AnimatedImageCompositor.class);
  PowerMockito.whenNew(AnimatedImageCompositor.class)
      .withAnyArguments()
      .thenReturn(mockCompositor);

  ImageDecodeOptions imageDecodeOptions =
      ImageDecodeOptions.newBuilder()
          .setDecodePreviewFrame(true)
          .setDecodeAllFrames(true)
          .build();

  EncodedImage encodedImage =
      new EncodedImage(CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
  encodedImage.setImageFormat(ImageFormat.UNKNOWN);

  CloseableAnimatedImage closeableImage =
      (CloseableAnimatedImage)
          mAnimatedImageFactory.decodeGif(
              encodedImage, imageDecodeOptions, DEFAULT_BITMAP_CONFIG);

  // Verify we got the right result
  AnimatedImageResult imageResult = closeableImage.getImageResult();
  assertSame(mockGifImage, imageResult.getImage());
  assertNotNull(imageResult.getDecodedFrame(0));
  assertNotNull(imageResult.getDecodedFrame(1));
  assertNotNull(imageResult.getPreviewBitmap());

  // Should not have interacted with these.
  verify(mMockAnimatedDrawableBackendProvider)
      .get(any(AnimatedImageResult.class), isNull(Rect.class));
  verifyNoMoreInteractions(mMockAnimatedDrawableBackendProvider);
  verify(mMockBitmapFactory, times(2)).createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG);
  verifyNoMoreInteractions(mMockBitmapFactory);
  verify(mockCompositor).renderFrame(0, mockBitmap1);
  verify(mockCompositor).renderFrame(1, mockBitmap2);
}
 
Example #18
Source File: TestAnimatedDrawableBackend.java    From fresco with MIT License 4 votes vote down vote up
@Override
public AnimatedImageResult getAnimatedImageResult() {
  return null;
}
 
Example #19
Source File: AnimatedImageFactoryWebPImplTest.java    From fresco with MIT License 4 votes vote down vote up
private void testCreateWithDecodeAlFrames(
    WebPImage mockWebPImage, PooledByteBuffer byteBuffer, Bitmap mockBitmap1, Bitmap mockBitmap2)
    throws Exception {
  // For decoding preview frame, expect some calls.
  final AnimatedDrawableBackend mockAnimatedDrawableBackend =
      createAnimatedDrawableBackendMock(2);
  when(mMockAnimatedDrawableBackendProvider.get(
          any(AnimatedImageResult.class), isNull(Rect.class)))
      .thenReturn(mockAnimatedDrawableBackend);

  when(mMockBitmapFactory.createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG))
      .thenReturn(CloseableReference.of(mockBitmap1, FAKE_BITMAP_RESOURCE_RELEASER))
      .thenReturn(CloseableReference.of(mockBitmap2, FAKE_BITMAP_RESOURCE_RELEASER));
  AnimatedImageCompositor mockCompositor = mock(AnimatedImageCompositor.class);
  PowerMockito.whenNew(AnimatedImageCompositor.class)
      .withAnyArguments()
      .thenReturn(mockCompositor);

  ImageDecodeOptions imageDecodeOptions =
      ImageDecodeOptions.newBuilder()
          .setDecodePreviewFrame(true)
          .setDecodeAllFrames(true)
          .build();

  EncodedImage encodedImage =
      new EncodedImage(CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
  encodedImage.setImageFormat(ImageFormat.UNKNOWN);

  CloseableAnimatedImage closeableImage =
      (CloseableAnimatedImage)
          mAnimatedImageFactory.decodeWebP(
              encodedImage, imageDecodeOptions, DEFAULT_BITMAP_CONFIG);

  // Verify we got the right result
  AnimatedImageResult imageResult = closeableImage.getImageResult();
  assertSame(mockWebPImage, imageResult.getImage());
  assertNotNull(imageResult.getDecodedFrame(0));
  assertNotNull(imageResult.getDecodedFrame(1));
  assertNotNull(imageResult.getPreviewBitmap());

  // Should not have interacted with these.
  verify(mMockAnimatedDrawableBackendProvider)
      .get(any(AnimatedImageResult.class), isNull(Rect.class));
  verifyNoMoreInteractions(mMockAnimatedDrawableBackendProvider);
  verify(mMockBitmapFactory, times(2)).createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG);
  verifyNoMoreInteractions(mMockBitmapFactory);
  verify(mockCompositor).renderFrame(0, mockBitmap1);
  verify(mockCompositor).renderFrame(1, mockBitmap2);
}
 
Example #20
Source File: AnimatedDrawableBackendImpl.java    From fresco with MIT License 4 votes vote down vote up
@Override
public AnimatedImageResult getAnimatedImageResult() {
  return mAnimatedImageResult;
}
 
Example #21
Source File: CloseableAnimatedImage.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
public CloseableAnimatedImage(AnimatedImageResult imageResult) {
  mImageResult = imageResult;
}
 
Example #22
Source File: CloseableAnimatedImage.java    From fresco with MIT License 4 votes vote down vote up
public synchronized AnimatedImageResult getImageResult() {
  return mImageResult;
}
 
Example #23
Source File: CloseableAnimatedImage.java    From fresco with MIT License 4 votes vote down vote up
public CloseableAnimatedImage(AnimatedImageResult imageResult, boolean isStateful) {
  mImageResult = imageResult;
  mIsStateful = isStateful;
}
 
Example #24
Source File: CloseableAnimatedImage.java    From fresco with MIT License 4 votes vote down vote up
public CloseableAnimatedImage(AnimatedImageResult imageResult) {
  this(imageResult, true);
}
 
Example #25
Source File: ExperimentalBitmapAnimationDrawableFactory.java    From fresco with MIT License 4 votes vote down vote up
private AnimatedFrameCache createAnimatedFrameCache(
    final AnimatedImageResult animatedImageResult) {
  return new AnimatedFrameCache(
      new AnimationFrameCacheKey(animatedImageResult.hashCode()), mBackingCache);
}
 
Example #26
Source File: ExperimentalBitmapAnimationDrawableFactory.java    From fresco with MIT License 4 votes vote down vote up
private AnimatedDrawableBackend createAnimatedDrawableBackend(
    AnimatedImageResult animatedImageResult) {
  AnimatedImage animatedImage = animatedImageResult.getImage();
  Rect initialBounds = new Rect(0, 0, animatedImage.getWidth(), animatedImage.getHeight());
  return mAnimatedDrawableBackendProvider.get(animatedImageResult, initialBounds);
}
 
Example #27
Source File: AnimatedDrawableBackendImpl.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
@Override
public AnimatedImageResult getAnimatedImageResult() {
  return mAnimatedImageResult;
}
 
Example #28
Source File: ImagePipelineConfig.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
private ImagePipelineConfig(Builder builder) {
  mBitmapMemoryCacheParamsSupplier =
      builder.mBitmapMemoryCacheParamsSupplier == null ?
          new DefaultBitmapMemoryCacheParamsSupplier(
              (ActivityManager) builder.mContext.getSystemService(Context.ACTIVITY_SERVICE)) :
          builder.mBitmapMemoryCacheParamsSupplier;
  mCacheKeyFactory =
      builder.mCacheKeyFactory == null ?
          DefaultCacheKeyFactory.getInstance() :
          builder.mCacheKeyFactory;
  mContext = Preconditions.checkNotNull(builder.mContext);
  mEncodedMemoryCacheParamsSupplier =
      builder.mEncodedMemoryCacheParamsSupplier == null ?
          new DefaultEncodedMemoryCacheParamsSupplier() :
          builder.mEncodedMemoryCacheParamsSupplier;
  mExecutorSupplier =
      builder.mExecutorSupplier == null ?
          new DefaultExecutorSupplier() :
          builder.mExecutorSupplier;
  mImageCacheStatsTracker =
      builder.mImageCacheStatsTracker == null ?
          NoOpImageCacheStatsTracker.getInstance() :
          builder.mImageCacheStatsTracker;
  mIsPrefetchEnabledSupplier =
        builder.mIsPrefetchEnabledSupplier == null ?
            new Supplier<Boolean>() {
              @Override
              public Boolean get() {
                return true;
              }
            } :
            builder.mIsPrefetchEnabledSupplier;
  mMainDiskCacheConfig =
      builder.mMainDiskCacheConfig == null ?
          getDefaultMainDiskCacheConfig(builder.mContext) :
          builder.mMainDiskCacheConfig;
  mMemoryTrimmableRegistry =
      builder.mMemoryTrimmableRegistry == null ?
          NoOpMemoryTrimmableRegistry.getInstance() :
          builder.mMemoryTrimmableRegistry;
  mPoolFactory =
      builder.mPoolFactory == null ?
          new PoolFactory(PoolConfig.newBuilder().build()) :
          builder.mPoolFactory;
  mProgressiveJpegConfig =
      builder.mProgressiveJpegConfig == null ?
          getDefaultProgressiveJpegConfig() :
          builder.mProgressiveJpegConfig;
  mRequestListeners =
      builder.mRequestListeners == null ?
          new HashSet<RequestListener>() :
          builder.mRequestListeners;
  mResizeAndRotateEnabledForNetwork = builder.mResizeAndRotateEnabledForNetwork;
  mSmallImageDiskCacheConfig =
      builder.mSmallImageDiskCacheConfig == null ?
          mMainDiskCacheConfig :
          builder.mSmallImageDiskCacheConfig;

  mAnimatedDrawableUtil = new AnimatedDrawableUtil();
  AnimatedDrawableBackendProvider animatedDrawableBackendProvider =
      new AnimatedDrawableBackendProvider() {
    @Override
    public AnimatedDrawableBackend get(AnimatedImageResult imageResult, Rect bounds) {
      return new AnimatedDrawableBackendImpl(mAnimatedDrawableUtil, imageResult, bounds);
    }
  };
  mAnimatedImageFactory = builder.mAnimatedImageFactory == null ?
      new AnimatedImageFactory(animatedDrawableBackendProvider) :
      builder.mAnimatedImageFactory;

  GingerbreadBitmapFactory factoryGingerbread = new GingerbreadBitmapFactory();
  DalvikBitmapFactory factoryICS = new DalvikBitmapFactory(
      new EmptyJpegGenerator(mPoolFactory.getPooledByteBufferFactory()),
      mPoolFactory.getSingleByteArrayPool());
  ArtBitmapFactory factoryLollipop =
      new ArtBitmapFactory(mPoolFactory.getBitmapPool());
  mPlatformBitmapFactory =
      new PlatformBitmapFactory(
          factoryGingerbread,
          factoryICS,
          factoryLollipop);

  mImageDecoder =
      builder.mImageDecoder == null ?
          new ImageDecoder(mAnimatedImageFactory, mPlatformBitmapFactory) :
          builder.mImageDecoder;
  mNetworkFetchProducer =
      builder.mNetworkFetchProducer == null ?
          new HttpURLConnectionNetworkFetchProducer(
              mPoolFactory.getPooledByteBufferFactory(),
              mPoolFactory.getCommonByteArrayPool()) :
          builder.mNetworkFetchProducer;
}
 
Example #29
Source File: CloseableAnimatedImage.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
public synchronized AnimatedImageResult getImageResult() {
  return mImageResult;
}
 
Example #30
Source File: AnimatedDrawableBackendProvider.java    From fresco with MIT License 2 votes vote down vote up
/**
 * Creates a new {@link AnimatedDrawableBackend}.
 *
 * @param animatedImageResult the image result.
 * @param bounds the initial bounds for the drawable
 * @return a new {@link AnimatedDrawableBackend}
 */
AnimatedDrawableBackend get(AnimatedImageResult animatedImageResult, Rect bounds);