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

The following examples show how to use com.facebook.imagepipeline.animated.base.AnimatedDrawable. 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: BoxingFrescoLoader.java    From boxing with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: AnimatedDrawableFactory.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
private AnimatedDrawable createAnimatedDrawable(
    AnimatedDrawableOptions options,
    AnimatedDrawableBackend animatedDrawableBackend) {
  DisplayMetrics displayMetrics = mResources.getDisplayMetrics();
  AnimatedDrawableDiagnostics animatedDrawableDiagnostics;
  AnimatedDrawableCachingBackend animatedDrawableCachingBackend =
      mAnimatedDrawableCachingBackendProvider.get(
          animatedDrawableBackend,
          options);
  if (options.enableDebugging) {
    animatedDrawableDiagnostics =
        new AnimatedDrawableDiagnosticsImpl(mAnimatedDrawableUtil, displayMetrics);
  } else {
    animatedDrawableDiagnostics = AnimatedDrawableDiagnosticsNoop.getInstance();
  }

  return new AnimatedDrawable(
      mScheduledExecutorServiceForUiThread,
      animatedDrawableCachingBackend,
      animatedDrawableDiagnostics,
      mMonotonicClock);
}
 
Example #3
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 #4
Source File: CanViewPagerActivity.java    From CanPhotos with Apache License 2.0 3 votes vote down vote up
private void handleAnimateBitmap(CloseableAnimatedImage animatedImage, int position) {

        AnimatedDrawableFactory animatedDrawableFactory =
                Fresco.getImagePipelineFactory().getAnimatedDrawableFactory();
        AnimatedDrawable drawable =
                animatedDrawableFactory.create(animatedImage.getImageResult());

        Bitmap bitmap = drawable2Bitmap(drawable);
        map.put(position, bitmap);


    }
 
Example #5
Source File: AnimatedDrawableFactory.java    From FanXin-based-HuanXin with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates an {@link AnimatedDrawable} based on an {@link AnimatedImage}.
 *
 * @param animatedImageResult the result of the code
 * @return a newly constructed {@link AnimatedDrawable}
 */
public AnimatedDrawable create(AnimatedImageResult animatedImageResult) {
  return create(animatedImageResult, AnimatedDrawableOptions.DEFAULTS);
}