@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); }
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); }
private void assertRoundingParams( RoundingParams roundingParams, Rounded roundedDrawable) { assertNotNull(roundedDrawable); if (roundingParams == null) { // default rounding params, no rounding specified roundingParams = new RoundingParams(); } if (roundingParams.getCornersRadii() == null) { // create a zero radii array if null roundingParams.setCornersRadius(0); } assertEquals(roundingParams.getRoundAsCircle(), roundedDrawable.isCircle()); assertArrayEquals(roundingParams.getCornersRadii(), roundedDrawable.getRadii(), 0f); assertEquals(roundingParams.getBorderColor(), roundedDrawable.getBorderColor()); assertEquals(roundingParams.getBorderWidth(), roundedDrawable.getBorderWidth(), 0f); assertEquals(roundingParams.getPadding(), roundedDrawable.getPadding(), 0f); }
/** * Applies the given rounding params on the specified rounded drawable. */ static void applyRoundingParams(Rounded rounded, RoundingParams roundingParams) { rounded.setCircle(roundingParams.getRoundAsCircle()); rounded.setRadii(roundingParams.getCornersRadii()); rounded.setBorder(roundingParams.getBorderColor(), roundingParams.getBorderWidth()); rounded.setPadding(roundingParams.getPadding()); }
/** * Resets the rounding params on the specified rounded drawable, so that no rounding occurs. */ static void resetRoundingParams(Rounded rounded) { rounded.setCircle(false); rounded.setRadius(0); rounded.setBorder(Color.TRANSPARENT, 0); rounded.setPadding(0); }
/** * Applies the given rounding params on the specified rounded drawable. */ static void applyRoundingParams(Rounded rounded, RoundingParams roundingParams) { rounded.setCircle(roundingParams.getRoundAsCircle()); rounded.setRadii(roundingParams.getCornersRadii()); rounded.setBorder(roundingParams.getBorderColor(), roundingParams.getBorderWidth()); rounded.setPadding(roundingParams.getPadding()); rounded.setScaleDownInsideBorders(roundingParams.getScaleDownInsideBorders()); }
/** * Resets the rounding params on the specified rounded drawable, so that no rounding occurs. */ static void resetRoundingParams(Rounded rounded) { rounded.setCircle(false); rounded.setRadius(0); rounded.setBorder(Color.TRANSPARENT, 0); rounded.setPadding(0); rounded.setScaleDownInsideBorders(false); }
private static void applyRoundingParams(Rounded rounded, RoundingParams roundingParams) { rounded.setCircle(roundingParams.getRoundAsCircle()); rounded.setRadii(roundingParams.getCornersRadii()); rounded.setBorder( roundingParams.getBorderColor(), roundingParams.getBorderWidth()); }