Java 类com.facebook.drawee.drawable.Rounded 实例源码

项目:GitHub    文件:GenericDraweeHierarchyTest.java   
@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);
}
项目:GitHub    文件:GenericDraweeHierarchyTest.java   
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);
}
项目:GitHub    文件:GenericDraweeHierarchyTest.java   
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);
}
项目:fresco    文件:GenericDraweeHierarchyTest.java   
@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);
}
项目:fresco    文件:GenericDraweeHierarchyTest.java   
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);
}
项目:fresco    文件:GenericDraweeHierarchyTest.java   
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);
}
项目:GitHub    文件:WrappingUtils.java   
/**
 * 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());
}
项目:GitHub    文件:WrappingUtils.java   
/**
 * 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);
}
项目:fresco    文件:WrappingUtils.java   
/**
 * 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());
}
项目:fresco    文件:WrappingUtils.java   
/**
 * 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);
}
项目:S1-Go    文件:ImageLoader.java   
private static void applyRoundingParams(Rounded rounded, RoundingParams roundingParams) {
    rounded.setCircle(roundingParams.getRoundAsCircle());
    rounded.setRadii(roundingParams.getCornersRadii());
    rounded.setBorder(
            roundingParams.getBorderColor(),
            roundingParams.getBorderWidth());
}