com.facebook.drawee.drawable.OrientedDrawable Java Examples

The following examples show how to use com.facebook.drawee.drawable.OrientedDrawable. 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: DefaultDrawableFactory.java    From fresco with MIT License 5 votes vote down vote up
@Override
@Nullable
public Drawable createDrawable(CloseableImage closeableImage) {
  try {
    if (FrescoSystrace.isTracing()) {
      FrescoSystrace.beginSection("DefaultDrawableFactory#createDrawable");
    }
    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;
  } finally {
    if (FrescoSystrace.isTracing()) {
      FrescoSystrace.endSection();
    }
  }
}
 
Example #3
Source File: BitmapDrawableFactory.java    From fresco with MIT License 5 votes vote down vote up
protected Drawable rotatedDrawable(
    CloseableStaticBitmap closeableStaticBitmap, Drawable drawable) {
  if (!hasTransformableRotationAngle(closeableStaticBitmap)
      && !hasTransformableExifOrientation(closeableStaticBitmap)) {
    // Return the bitmap drawable directly as there's nothing to transform in it
    return drawable;
  } else {
    return new OrientedDrawable(
        drawable,
        closeableStaticBitmap.getRotationAngle(),
        closeableStaticBitmap.getExifOrientation());
  }
}