Search in sources :

Example 11 with FadeDrawable

use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.

the class GenericDraweeHierarchyTest method testHierarchy_WithPressedStateOverlay.

@Test
public void testHierarchy_WithPressedStateOverlay() throws Exception {
    GenericDraweeHierarchy dh = mBuilder.setOverlay(mOverlay2).setPressedStateOverlay(mOverlay1).build();
    RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
    FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
    assertEquals(8, fadeDrawable.getNumberOfLayers());
    assertSame(mOverlay2, fadeDrawable.getDrawable(6));
    StateListDrawable stateListDrawable = (StateListDrawable) fadeDrawable.getDrawable(7);
    assertNotNull(stateListDrawable);
}
Also used : FadeDrawable(com.facebook.drawee.drawable.FadeDrawable) StateListDrawable(android.graphics.drawable.StateListDrawable) Test(org.junit.Test)

Example 12 with FadeDrawable

use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.

the class GenericDraweeHierarchyTest method testHierarchy_WithOverlays.

@Test
public void testHierarchy_WithOverlays() throws Exception {
    GenericDraweeHierarchy dh = mBuilder.setOverlays(Arrays.asList(mOverlay1, mOverlay2)).build();
    RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
    FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
    assertEquals(8, fadeDrawable.getNumberOfLayers());
    assertSame(mOverlay1, fadeDrawable.getDrawable(6));
    assertSame(mOverlay2, fadeDrawable.getDrawable(7));
    verifyCallback(rootDrawable, mOverlay1);
    verifyCallback(rootDrawable, mOverlay2);
}
Also used : FadeDrawable(com.facebook.drawee.drawable.FadeDrawable) Test(org.junit.Test)

Example 13 with FadeDrawable

use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.

the class GenericDraweeHierarchyTest method testHierarchy_WithMatrix.

@Test
public void testHierarchy_WithMatrix() throws Exception {
    GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mPlaceholderImage, null).setRetryImage(mRetryImage, null).setFailureImage(mFailureImage, null).setProgressBarImage(mProgressBarImage, null).setActualImageMatrix(mActualImageMatrix).build();
    RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
    FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
    assertEquals(7, fadeDrawable.getNumberOfLayers());
    assertNull(fadeDrawable.getDrawable(0));
    assertSame(mPlaceholderImage, fadeDrawable.getDrawable(1));
    assertSame(mProgressBarImage, fadeDrawable.getDrawable(3));
    assertSame(mRetryImage, fadeDrawable.getDrawable(4));
    assertSame(mFailureImage, fadeDrawable.getDrawable(5));
    assertNull(fadeDrawable.getDrawable(6));
    MatrixDrawable matrixDrawable = (MatrixDrawable) fadeDrawable.getDrawable(2);
    assertNotNull(matrixDrawable);
    assertEquals(mActualImageMatrix, matrixDrawable.getMatrix());
    assertSame(ForwardingDrawable.class, matrixDrawable.getCurrent().getClass());
    verifyCallback(rootDrawable, mPlaceholderImage);
}
Also used : MatrixDrawable(com.facebook.drawee.drawable.MatrixDrawable) FadeDrawable(com.facebook.drawee.drawable.FadeDrawable) Test(org.junit.Test)

Example 14 with FadeDrawable

use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.

the class GenericDraweeHierarchyTest method testHierarchy_NoScaleTypeNorMatrix.

@Test
public void testHierarchy_NoScaleTypeNorMatrix() throws Exception {
    GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mPlaceholderImage, null).setRetryImage(mRetryImage, null).setFailureImage(mFailureImage, null).setProgressBarImage(mProgressBarImage, null).setActualImageScaleType(null).build();
    RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
    FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
    assertEquals(7, fadeDrawable.getNumberOfLayers());
    assertNull(fadeDrawable.getDrawable(0));
    assertSame(mPlaceholderImage, fadeDrawable.getDrawable(1));
    assertSame(ForwardingDrawable.class, fadeDrawable.getDrawable(2).getClass());
    assertSame(mProgressBarImage, fadeDrawable.getDrawable(3));
    assertSame(mRetryImage, fadeDrawable.getDrawable(4));
    assertSame(mFailureImage, fadeDrawable.getDrawable(5));
    assertNull(fadeDrawable.getDrawable(6));
    verifyCallback(rootDrawable, mPlaceholderImage);
}
Also used : FadeDrawable(com.facebook.drawee.drawable.FadeDrawable) Test(org.junit.Test)

Example 15 with FadeDrawable

use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.

the class GenericDraweeHierarchyTest method testHierarchy_WithAllBranches.

@Test
public void testHierarchy_WithAllBranches() throws Exception {
    GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mPlaceholderImage, ScaleType.CENTER).setRetryImage(mRetryImage, ScaleType.FIT_CENTER).setFailureImage(mFailureImage, ScaleType.FIT_CENTER).setProgressBarImage(mProgressBarImage, ScaleType.CENTER).setActualImageScaleType(ScaleType.CENTER_CROP).build();
    RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
    FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
    assertEquals(7, fadeDrawable.getNumberOfLayers());
    assertNull(fadeDrawable.getDrawable(0));
    assertScaleTypeAndDrawable(mPlaceholderImage, ScaleType.CENTER, fadeDrawable.getDrawable(1));
    assertActualImageScaleType(ScaleType.CENTER_CROP, null, fadeDrawable.getDrawable(2));
    assertScaleTypeAndDrawable(mProgressBarImage, ScaleType.CENTER, fadeDrawable.getDrawable(3));
    assertScaleTypeAndDrawable(mRetryImage, ScaleType.FIT_CENTER, fadeDrawable.getDrawable(4));
    assertScaleTypeAndDrawable(mFailureImage, ScaleType.FIT_CENTER, fadeDrawable.getDrawable(5));
    assertNull(fadeDrawable.getDrawable(6));
    verifyCallback(rootDrawable, mPlaceholderImage);
}
Also used : FadeDrawable(com.facebook.drawee.drawable.FadeDrawable) Test(org.junit.Test)

Aggregations

FadeDrawable (com.facebook.drawee.drawable.FadeDrawable)26 Test (org.junit.Test)22 ForwardingDrawable (com.facebook.drawee.drawable.ForwardingDrawable)4 RoundedCornersDrawable (com.facebook.drawee.drawable.RoundedCornersDrawable)3 ScaleTypeDrawable (com.facebook.drawee.drawable.ScaleTypeDrawable)3 StateListDrawable (android.graphics.drawable.StateListDrawable)2 PointF (android.graphics.PointF)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 MatrixDrawable (com.facebook.drawee.drawable.MatrixDrawable)1 Rounded (com.facebook.drawee.drawable.Rounded)1 RoundedBitmapDrawable (com.facebook.drawee.drawable.RoundedBitmapDrawable)1 ScaleType (com.facebook.drawee.drawable.ScalingUtils.ScaleType)1