Java Code Examples for com.facebook.drawee.generic.GenericDraweeHierarchy#setRoundingParams()

The following examples show how to use com.facebook.drawee.generic.GenericDraweeHierarchy#setRoundingParams() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CircleImageView.java    From JD-Test with Apache License 2.0 5 votes vote down vote up
/**
 * 使用代码设置为圆圈形状
 */
private void initCircleImage() {
    GenericDraweeHierarchy hierarchy = getHierarchy();
    if(hierarchy != null){
        hierarchy.setRoundingParams(new RoundingParams().setRoundAsCircle(true));
        setHierarchy(hierarchy);
    }
}
 
Example 2
Source File: DraweeRoundedCornersFragment.java    From fresco with MIT License 5 votes vote down vote up
private void changeDraweeViewScaleType(
    SimpleDraweeView draweeView, ScaleType scaleType, @Nullable PointF focusPoint) {
  final GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
  hierarchy.setActualImageScaleType(scaleType);
  hierarchy.setActualImageFocusPoint(focusPoint != null ? focusPoint : new PointF(0.5f, 0.5f));

  final RoundingParams roundingParams = Preconditions.checkNotNull(hierarchy.getRoundingParams());
  if (BITMAP_ONLY_SCALETYPES.contains(scaleType)) {
    roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  } else {
    roundingParams.setOverlayColor(mWindowBackgroundColor);
  }
  hierarchy.setRoundingParams(roundingParams);
}
 
Example 3
Source File: FrescoImageHierarchyTools.java    From litho with Apache License 2.0 4 votes vote down vote up
public static void setupHierarchy(
    @Prop(optional = true) ScalingUtils.ScaleType actualImageScaleType,
    @Prop(optional = true) PointF actualImageFocusPoint,
    @Prop(optional = true) int fadeDuration,
    @Prop(optional = true, resType = DRAWABLE) Drawable failureImage,
    @Prop(optional = true) ScalingUtils.ScaleType failureImageScaleType,
    @Prop(optional = true, resType = DRAWABLE) Drawable placeholderImage,
    @Prop(optional = true) PointF placeholderImageFocusPoint,
    @Prop(optional = true) ScalingUtils.ScaleType placeholderImageScaleType,
    @Prop(optional = true, resType = DRAWABLE) Drawable progressBarImage,
    @Prop(optional = true) ScalingUtils.ScaleType progressBarImageScaleType,
    @Prop(optional = true, resType = DRAWABLE) Drawable retryImage,
    @Prop(optional = true) ScalingUtils.ScaleType retryImageScaleType,
    @Prop(optional = true) RoundingParams roundingParams,
    @Prop(optional = true) ColorFilter colorFilter,
    GenericDraweeHierarchy draweeHierarchy) {

  if (placeholderImage == null) {
    draweeHierarchy.setPlaceholderImage(null);
  } else {
    draweeHierarchy.setPlaceholderImage(placeholderImage, placeholderImageScaleType);
  }

  if (placeholderImageScaleType == ScalingUtils.ScaleType.FOCUS_CROP) {
    draweeHierarchy.setPlaceholderImageFocusPoint(placeholderImageFocusPoint);
  }

  draweeHierarchy.setActualImageScaleType(actualImageScaleType);
  if (actualImageFocusPoint != null
      && actualImageScaleType == ScalingUtils.ScaleType.FOCUS_CROP) {
    draweeHierarchy.setActualImageFocusPoint(actualImageFocusPoint);
  }
  draweeHierarchy.setFadeDuration(fadeDuration);

  if (failureImage == null) {
    draweeHierarchy.setFailureImage(null);
  } else {
    draweeHierarchy.setFailureImage(failureImage, failureImageScaleType);
  }

  if (progressBarImage == null) {
    draweeHierarchy.setProgressBarImage(null);
  } else {
    draweeHierarchy.setProgressBarImage(progressBarImage, progressBarImageScaleType);
  }

  if (retryImage == null) {
    draweeHierarchy.setRetryImage(null);
  } else {
    draweeHierarchy.setRetryImage(retryImage, retryImageScaleType);
  }

  draweeHierarchy.setRoundingParams(roundingParams);
  draweeHierarchy.setActualImageColorFilter(colorFilter);
}