Search in sources :

Example 26 with ImageOptions

use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.

the class HierarcherImplTest method testBuildErrorDrawable_whenScaleTypeNull_thenDoNotWrapDrawable.

@Test
public void testBuildErrorDrawable_whenScaleTypeNull_thenDoNotWrapDrawable() {
    ImageOptions options = ImageOptions.create().errorRes(RES_ID).errorScaleType(null).build();
    Drawable errorDrawable = mHierarcher.buildErrorDrawable(mResources, options);
    assertThat(errorDrawable).isEqualTo(mDrawable);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) ScaleTypeDrawable(com.facebook.drawee.drawable.ScaleTypeDrawable) RoundedColorDrawable(com.facebook.drawee.drawable.RoundedColorDrawable) RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) Test(org.junit.Test)

Example 27 with ImageOptions

use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.

the class HierarcherImplTest method testBuildPlaceholderRes.

@Test
public void testBuildPlaceholderRes() {
    ImageOptions options = ImageOptions.create().placeholderRes(RES_ID).build();
    Drawable errorDrawable = mHierarcher.buildPlaceholderDrawable(mResources, options);
    assertThat(errorDrawable).isNotNull();
    assertThat(errorDrawable).isInstanceOf(ScaleTypeDrawable.class);
    ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) errorDrawable;
    assertThat(scaleTypeDrawable.getScaleType()).isEqualTo(ImageOptions.defaults().getPlaceholderScaleType());
    assertThat(scaleTypeDrawable.getFocusPoint()).isEqualTo(ImageOptions.defaults().getPlaceholderFocusPoint());
    assertThat(scaleTypeDrawable.getCurrent()).isEqualTo(mDrawable);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) ScaleTypeDrawable(com.facebook.drawee.drawable.ScaleTypeDrawable) RoundedColorDrawable(com.facebook.drawee.drawable.RoundedColorDrawable) RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) ScaleTypeDrawable(com.facebook.drawee.drawable.ScaleTypeDrawable) Test(org.junit.Test)

Example 28 with ImageOptions

use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.

the class HierarcherImplTest method testBuildPlaceholderDrawable.

@Test
public void testBuildPlaceholderDrawable() {
    final Drawable expected = new ColorDrawable(Color.YELLOW);
    ImageOptions options = ImageOptions.create().placeholder(expected).placeholderScaleType(null).build();
    final Drawable result = mHierarcher.buildPlaceholderDrawable(mResources, options);
    assertThat(result).isEqualTo(expected);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) RoundedColorDrawable(com.facebook.drawee.drawable.RoundedColorDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) ScaleTypeDrawable(com.facebook.drawee.drawable.ScaleTypeDrawable) RoundedColorDrawable(com.facebook.drawee.drawable.RoundedColorDrawable) RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) Test(org.junit.Test)

Example 29 with ImageOptions

use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.

the class BitmapDrawableFactoryTest method testCreateDrawable_whenRoundWithCornerRadii_thenReturnBitmapDrawable.

@Test
public void testCreateDrawable_whenRoundWithCornerRadii_thenReturnBitmapDrawable() {
    final CloseableStaticBitmap closeableImage = mock(CloseableStaticBitmap.class);
    final Bitmap bitmap = mock(Bitmap.class);
    when(closeableImage.getUnderlyingBitmap()).thenReturn(bitmap);
    final ImageOptions options = mock(ImageOptions.class);
    when(options.getRoundingOptions()).thenReturn(RoundingOptions.forCornerRadii(1, 2, 3, 4));
    when(closeableImage.getExtras()).thenReturn(mImageExtrasNotRounded);
    Drawable drawable = mDrawableFactory.createDrawable(closeableImage, options);
    assertThat(drawable).isNotNull();
    assertThat(drawable).isInstanceOf(RoundedBitmapDrawable.class);
    assertThat(((RoundedBitmapDrawable) drawable).getRadii()).isEqualTo(new float[] { 1, 1, 2, 2, 3, 3, 4, 4 });
}
Also used : RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable) Bitmap(android.graphics.Bitmap) CloseableStaticBitmap(com.facebook.imagepipeline.image.CloseableStaticBitmap) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) CloseableStaticBitmap(com.facebook.imagepipeline.image.CloseableStaticBitmap) Test(org.junit.Test)

Example 30 with ImageOptions

use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.

the class BitmapDrawableFactoryTest method testCreateDrawable_whenAlreadyRoundedWithBorder_thenReturnBitmapDrawable.

@Test
public void testCreateDrawable_whenAlreadyRoundedWithBorder_thenReturnBitmapDrawable() {
    final CloseableStaticBitmap closeableImage = mock(CloseableStaticBitmap.class);
    final Bitmap bitmap = mock(Bitmap.class);
    when(closeableImage.getUnderlyingBitmap()).thenReturn(bitmap);
    when(closeableImage.getExtras()).thenReturn(mImageExtrasRounded);
    final ImageOptions options = mock(ImageOptions.class);
    BorderOptions borderOptions = BorderOptions.create(Color.YELLOW, 10);
    when(options.getBorderOptions()).thenReturn(borderOptions);
    when(options.getRoundingOptions()).thenReturn(RoundingOptions.asCircle(false, false));
    Drawable drawable = mDrawableFactory.createDrawable(closeableImage, options);
    assertThat(drawable).isNotNull();
    assertThat(drawable).isInstanceOf(CircularBorderBitmapDrawable.class);
    assertThat(((CircularBorderBitmapDrawable) drawable).getBorder()).isEqualTo(borderOptions);
}
Also used : Bitmap(android.graphics.Bitmap) CloseableStaticBitmap(com.facebook.imagepipeline.image.CloseableStaticBitmap) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) BorderOptions(com.facebook.fresco.vito.options.BorderOptions) CloseableStaticBitmap(com.facebook.imagepipeline.image.CloseableStaticBitmap) Test(org.junit.Test)

Aggregations

ImageOptions (com.facebook.fresco.vito.options.ImageOptions)32 Test (org.junit.Test)32 BitmapDrawable (android.graphics.drawable.BitmapDrawable)21 Drawable (android.graphics.drawable.Drawable)21 RoundedBitmapDrawable (com.facebook.drawee.drawable.RoundedBitmapDrawable)21 ColorDrawable (android.graphics.drawable.ColorDrawable)14 RoundedColorDrawable (com.facebook.drawee.drawable.RoundedColorDrawable)14 ScaleTypeDrawable (com.facebook.drawee.drawable.ScaleTypeDrawable)14 Bitmap (android.graphics.Bitmap)8 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)7 CloseableStaticBitmap (com.facebook.imagepipeline.image.CloseableStaticBitmap)6 ImageDecodeOptions (com.facebook.imagepipeline.common.ImageDecodeOptions)4 Resources (android.content.res.Resources)2 PointF (android.graphics.PointF)2 ImageSource (com.facebook.fresco.vito.source.ImageSource)2 BorderOptions (com.facebook.fresco.vito.options.BorderOptions)1 ImageOptionsDrawableFactory (com.facebook.fresco.vito.options.ImageOptionsDrawableFactory)1 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)1 RotationOptions (com.facebook.imagepipeline.common.RotationOptions)1 CloseableImage (com.facebook.imagepipeline.image.CloseableImage)1