use of com.facebook.drawee.drawable.Rounded in project fresco by facebook.
the class GenericDraweeHierarchyTest method testHierarchy_WithRoundedLeafs.
@Test
public void testHierarchy_WithRoundedLeafs() throws Exception {
RoundingParams roundingParams = RoundingParams.asCircle();
GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mWrappedImage, ScaleType.CENTER).setFailureImage(mFailureImage, ScaleType.CENTER).setRetryImage(mRetryImage, null).setRoundingParams(roundingParams).build();
RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
assertNotNull(fadeDrawable);
assertScaleTypeAndDrawable(mWrappedImage, ScaleType.CENTER, fadeDrawable.getDrawable(1));
Rounded roundedPlaceholder = (Rounded) mWrappedImage.getCurrent().getCurrent();
assertRoundingParams(roundingParams, roundedPlaceholder);
Rounded roundedFailureImage = (Rounded) fadeDrawable.getDrawable(5).getCurrent();
assertRoundingParams(roundingParams, roundedFailureImage);
Rounded roundedRetryImage = (Rounded) fadeDrawable.getDrawable(4);
assertRoundingParams(roundingParams, roundedRetryImage);
verifyCallback(rootDrawable, mWrappedImage.getCurrent().getCurrent());
verifyCallback(rootDrawable, (Drawable) roundedFailureImage);
verifyCallback(rootDrawable, (Drawable) roundedRetryImage);
}
use of com.facebook.drawee.drawable.Rounded in project fresco by facebook.
the class WrappingUtils method updateLeafRounding.
/**
* Updates the leaf rounding of the parent's child drawable.
*
* <ul>
* <li>If rounding mode is BITMAP_ONLY and the child is not a rounded drawable,
* it gets rounded with a new rounded drawable.
* <li>If rounding mode is BITMAP_ONLY and the child is already rounded,
* its rounding parameters are updated.
* <li>If rounding mode is not BITMAP_ONLY and the child is rounded,
* its rounding parameters are reset so that no rounding occurs.
* </ul>
*/
static void updateLeafRounding(DrawableParent parent, @Nullable RoundingParams roundingParams, Resources resources) {
parent = findDrawableParentForLeaf(parent);
Drawable child = parent.getDrawable();
if (roundingParams != null && roundingParams.getRoundingMethod() == RoundingParams.RoundingMethod.BITMAP_ONLY) {
// drawable that will round it.
if (child instanceof Rounded) {
Rounded rounded = (Rounded) child;
applyRoundingParams(rounded, roundingParams);
} else if (child != null) {
// Important: remove the child before wrapping it with a new parent!
parent.setDrawable(sEmptyDrawable);
Drawable rounded = applyLeafRounding(child, roundingParams, resources);
parent.setDrawable(rounded);
}
} else if (child instanceof Rounded) {
// No rounding requested - reset rounding params so no rounding occurs.
resetRoundingParams((Rounded) child);
}
}
use of com.facebook.drawee.drawable.Rounded in project fresco by facebook.
the class GenericDraweeHierarchyTest method testRoundingParams_RoundedLeafs.
private void testRoundingParams_RoundedLeafs(RootDrawable rootDrawable, FadeDrawable fadeDrawable, RoundingParams roundingParams) {
assertNotNull(fadeDrawable);
assertScaleTypeAndDrawable(mWrappedImage, ScaleType.CENTER, fadeDrawable.getDrawable(1));
Rounded roundedPlaceholder = (Rounded) mWrappedImage.getCurrent().getCurrent();
assertRoundingParams(roundingParams, roundedPlaceholder);
Rounded roundedFailureImage = (Rounded) fadeDrawable.getDrawable(5).getCurrent();
assertRoundingParams(roundingParams, roundedFailureImage);
Rounded roundedRetryImage = (Rounded) fadeDrawable.getDrawable(4);
assertRoundingParams(roundingParams, roundedRetryImage);
verifyCallback(rootDrawable, (Drawable) roundedPlaceholder);
verifyCallback(rootDrawable, (Drawable) roundedFailureImage);
verifyCallback(rootDrawable, (Drawable) roundedRetryImage);
}
Aggregations