com.facebook.drawee.generic.RoundingParams Java Examples

The following examples show how to use com.facebook.drawee.generic.RoundingParams. 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: UETFresco.java    From UETool with MIT License 6 votes vote down vote up
private String getCornerRadius(DraweeView draweeView) {
    GenericDraweeHierarchy hierarchy = getGenericDraweeHierarchy(draweeView);
    if (hierarchy != null) {
        RoundingParams params = hierarchy.getRoundingParams();
        if (params != null) {
            float[] cornersRadii = params.getCornersRadii();
            if (cornersRadii != null) {
                float firstRadii = cornersRadii[0];
                for (int i = 1; i < 8; i++) {
                    if (firstRadii != cornersRadii[i]) {
                        return null;
                    }
                }
                return px2dip(firstRadii, true);
            }
        }
    }
    return null;
}
 
Example #2
Source File: FrescoConfig.java    From BlueBoard with Apache License 2.0 6 votes vote down vote up
public static GenericDraweeHierarchy getGenericDraweeHierarchy(Context context) {
        GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(context.getResources())
//            .reset()//重置
//            .setActualImageColorFilter(colorFilter)//颜色过滤
//            .setActualImageFocusPoint(focusPoint)//focusCrop, 需要指定一个居中点
//            .setActualImageMatrix(actualImageMatrix)
//            .setActualImageScaleType(actualImageScaleType)//fresco:actualImageScaleType="focusCrop"缩放类型
//            .setBackground(background)//fresco:backgroundImage="@color/blue"背景图片
//            .setBackgrounds(backgrounds)
//            .setFadeDuration(fadeDuration)//fresco:fadeDuration="300"加载图片动画时间
                .setFailureImage(FrescoConfig.sErrorDrawable)//fresco:failureImage="@drawable/error"失败图
//            .setFailureImage(failureDrawable, failureImageScaleType)//fresco:failureImageScaleType="centerInside"失败图缩放类型
//            .setOverlay(overlay)//fresco:overlayImage="@drawable/watermark"叠加图
//            .setOverlays(overlays)
                .setPlaceholderImage(FrescoConfig.sPlaceholderDrawable)//fresco:placeholderImage="@color/wait_color"占位图
//            .setPlaceholderImage(placeholderDrawable, placeholderImageScaleType)//fresco:placeholderImageScaleType="fitCenter"占位图缩放类型
//            .setPressedStateOverlay(drawable)//fresco:pressedStateOverlayImage="@color/red"按压状态下的叠加图
                .setProgressBarImage(new ProgressBarDrawable())//进度条fresco:progressBarImage="@drawable/progress_bar"进度条
//            .setProgressBarImage(progressBarImage, progressBarImageScaleType)//fresco:progressBarImageScaleType="centerInside"进度条类型
//            .setRetryImage(retryDrawable)//fresco:retryImage="@drawable/retrying"点击重新加载
//            .setRetryImage(retryDrawable, retryImageScaleType)//fresco:retryImageScaleType="centerCrop"点击重新加载缩放类型
                .setRoundingParams(RoundingParams.asCircle())//圆形/圆角fresco:roundAsCircle="true"圆形
                .build();
        return gdh;
    }
 
Example #3
Source File: AvatarView.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
public void init(int size, float placeholderTextSize) {
    this.size = size;
    this.placeholderTextSize = placeholderTextSize;

    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(getResources());

    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .setRoundingParams(new RoundingParams()
                    .setRoundAsCircle(true)
                    .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY))
            //.setActualImageColorFilter(new PorterDuffColorFilter(0x19000000, PorterDuff.Mode.MULTIPLY))
            //.setOverlay(new AvatarBorderDrawable())
            .build();
    setHierarchy(hierarchy);
}
 
Example #4
Source File: FrescoImageSpec.java    From litho with Apache License 2.0 5 votes vote down vote up
@OnMount
protected static void onMount(
    ComponentContext c,
    DraweeDrawable<GenericDraweeHierarchy> draweeDrawable,
    @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 = draweeDrawable.getDraweeHierarchy();

  FrescoImageHierarchyTools.setupHierarchy(
      actualImageScaleType,
      actualImageFocusPoint,
      fadeDuration,
      failureImage,
      failureImageScaleType,
      placeholderImage,
      placeholderImageFocusPoint,
      placeholderImageScaleType,
      progressBarImage,
      progressBarImageScaleType,
      retryImage,
      retryImageScaleType,
      roundingParams,
      colorFilter,
      draweeHierarchy);

  draweeDrawable.mount();
}
 
Example #5
Source File: ImageLoaderUtil.java    From JD-Test with Apache License 2.0 5 votes vote down vote up
/**
 * 设置图片的原角半径(原来为圆角的不能修改为圆圈,反之亦然)
 * @param radius 圆角半径
 * @return this
 */
public ImageLoaderUtil setRoundingParams(float radius){
    RoundingParams roundingParams = hierarchy.getRoundingParams();
    if(roundingParams == null){
        hierarchy.setRoundingParams(new RoundingParams().setCornersRadius(radius));
    }else{
        roundingParams.setCornersRadius(radius);
        hierarchy.setRoundingParams(roundingParams);
    }

    return this;
}
 
Example #6
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 #7
Source File: ShareLocationActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
private SimpleDraweeView createDraweeView() {
    SimpleDraweeView view = new SimpleDraweeView(this);
    RoundingParams params = RoundingParams.asCircle();
    view.setLayoutParams(new ViewGroup.LayoutParams(Utils.dpToPx(this, 48), Utils.dpToPx(this, 48)));
    GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources())
            .setPlaceholderImage(getResources().getDrawable(R.drawable.atom_ui_default_gravatar), ScalingUtils.ScaleType.CENTER_CROP)
            .setRoundingParams(params)
            .build();
    view.setHierarchy(hierarchy);
    return view;
}
 
Example #8
Source File: FrescoConfig.java    From BlueBoard with Apache License 2.0 5 votes vote down vote up
public static RoundingParams getRoundingParams() {
        RoundingParams roundingParams = RoundingParams.fromCornersRadius(7f);
//    roundingParams.asCircle();//圆形
//    roundingParams.setBorder(color, width);//fresco:roundingBorderWidth="2dp"边框  fresco:roundingBorderColor="@color/border_color"
//    roundingParams.setCornersRadii(radii);//半径
//    roundingParams.setCornersRadii(topLeft, topRight, bottomRight, bottomLeft)//fresco:roundTopLeft="true" fresco:roundTopRight="false" fresco:roundBottomLeft="false" fresco:roundBottomRight="true"
//    roundingParams. setCornersRadius(radius);//fresco:roundedCornerRadius="1dp"圆角
//    roundingParams.setOverlayColor(overlayColor);//fresco:roundWithOverlayColor="@color/corner_color"
//    roundingParams.setRoundAsCircle(roundAsCircle);//圆
//    roundingParams.setRoundingMethod(roundingMethod);
//    fresco:progressBarAutoRotateInterval="1000"自动旋转间隔
        // 或用 fromCornersRadii 以及 asCircle 方法
        return roundingParams;
    }
 
Example #9
Source File: DraweeUtil.java    From fresco with MIT License 5 votes vote down vote up
/**
 * Creates the Hierarchy using the information into the Config
 *
 * @param context The Context
 * @param config The Config object
 * @return The Hierarchy to use
 */
public static GenericDraweeHierarchy createDraweeHierarchy(
    final Context context, final Config config) {
  FrescoSystrace.beginSection("DraweeUtil#createDraweeHierarchy");
  GenericDraweeHierarchyBuilder builder =
      new GenericDraweeHierarchyBuilder(context.getResources())
          .setFadeDuration(config.fadeDurationMs)
          .setPlaceholderImage(Const.PLACEHOLDER)
          .setFailureImage(Const.FAILURE)
          .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
  applyScaleType(builder, config);

  if (config.useRoundedCorners || config.drawBorder) {
    final Resources res = context.getResources();
    final RoundingParams roundingParams = new RoundingParams();

    if (config.useRoundedCorners) {
      roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
      roundingParams.setCornersRadius(res.getDimensionPixelSize(R.dimen.drawee_corner_radius));
      roundingParams.setRoundAsCircle(config.useRoundedAsCircle);
    }

    if (config.drawBorder) {
      //noinspection deprecation
      roundingParams.setBorderColor(res.getColor(R.color.colorPrimary));
      roundingParams.setBorderWidth(res.getDimensionPixelSize(R.dimen.drawee_border_width));
    }

    builder.setRoundingParams(roundingParams);
  }
  GenericDraweeHierarchy result = builder.build();
  FrescoSystrace.endSection();
  return result;
}
 
Example #10
Source File: DraweeRoundedCornersFragment.java    From fresco with MIT License 5 votes vote down vote up
private void setShowBorder(SimpleDraweeView draweeView, boolean show, boolean scaleInside) {
  final RoundingParams roundingParams =
      Preconditions.checkNotNull(draweeView.getHierarchy().getRoundingParams());
  if (show) {
    roundingParams.setBorder(
        mColorPrimary,
        getResources().getDimensionPixelSize(R.dimen.drawee_rounded_corners_border_width));
    roundingParams.setScaleDownInsideBorders(scaleInside);
  } else {
    roundingParams.setBorder(Color.TRANSPARENT, 0);
  }
  draweeView.getHierarchy().setRoundingParams(roundingParams);
}
 
Example #11
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 #12
Source File: DialogView.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void initStyles() {
        GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
                .setFadeDuration(0)
                .setRoundingParams(new RoundingParams()
                        .setRoundAsCircle(true))
                .build();
        draweeHolder = DraweeHolder.create(hierarchy, getContext());
        draweeHolder.getTopLevelDrawable().setCallback(this);

        setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(72)));
        setDividerPaddingLeft(Screen.dp(72));

//        setLayerType(LAYER_TYPE_HARDWARE, null);
    }
 
Example #13
Source File: LocationHolder.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public LocationHolder(MessagesAdapter adapter, View itemView, Peer peer) {
    super(adapter, itemView, false);
    this.context = adapter.getMessagesFragment().getActivity();

    COLOR_PENDING = ActorSDK.sharedActor().style.getConvMediaStatePendingColor();
    COLOR_SENT = ActorSDK.sharedActor().style.getConvMediaStateSentColor();
    COLOR_RECEIVED = ActorSDK.sharedActor().style.getConvMediaStateDeliveredColor();
    COLOR_READ = ActorSDK.sharedActor().style.getConvMediaStateReadColor();
    COLOR_ERROR = ActorSDK.sharedActor().style.getConvMediaStateErrorColor();

    messageBubble = (FrameLayout) itemView.findViewById(R.id.bubbleContainer);

    // Content
    previewView = (SimpleDraweeView) itemView.findViewById(R.id.image);
    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(context.getResources());

    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .setRoundingParams(new RoundingParams()
                    .setCornersRadius(Screen.dp(2))
                    .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY))
            .build();
    previewView.setHierarchy(hierarchy);

    time = (TextView) itemView.findViewById(R.id.time);

    stateIcon = (TintImageView) itemView.findViewById(R.id.stateIcon);
    onConfigureViewHolder();
}
 
Example #14
Source File: BackgroundPreviewView.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public void init(int width, int height, int corenerRadius) {
    this.width = width;
    this.height = height;

    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(getResources());

    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .setRoundingParams(new RoundingParams()
                    .setCornersRadius(corenerRadius)
                    .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY))
            .build();
    setHierarchy(hierarchy);
}
 
Example #15
Source File: DateDetailActivity.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setData(Date data) {
    getExpansion().dismissProgressPage();
    avatar.setImageURI(Uri.parse(data.getAuthorAvatar()));
    name.setText(data.getAuthorName());
    title.setText(data.getTitle());
    strTitle = data.getTitle();
    time.setText(new JTimeTransform(data.getTime()).toString(new JTimeTransform.RecentDateFormat()));
    dateTime.setText(new SimpleDateFormat("yyyy年MM月dd日").format(new java.util.Date(data.getAcTime())));
    content.setText(data.getContent());
    int uid = AccountModel.getInstance().getAccount().getUID();
    for (PersonBrief personBrief : data.getEnrollMember()) {
        if (personBrief.getUID() == uid) {
            joined = true;
            join.setText("进入");
        }
        SimpleDraweeView draweeView = new SimpleDraweeView(DateDetailActivity.this);
        draweeView.setLayoutParams(new ViewGroup.LayoutParams(JUtils.dip2px(40), JUtils.dip2px(40)));
        draweeView.setImageURI(Uri.parse(personBrief.getAvatar()));
        draweeView.getHierarchy().setRoundingParams(RoundingParams.asCircle());
        draweeView.setOnClickListener(v -> {
            Intent i = new Intent(DateDetailActivity.this, UserDetailActivity.class);
            i.putExtra("id", personBrief.getUID());
            startActivity(i);
        });
        joinMember.addView(draweeView);
    }
}
 
Example #16
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);
}
 
Example #17
Source File: MainActivity.java    From Fresco with Apache License 2.0 4 votes vote down vote up
private void initView() {

        //获取SimpleDraweeView
        sdv = (SimpleDraweeView) findViewById(R.id.main_sdv);

        //初始化圆角圆形参数对象
        RoundingParams rp = new RoundingParams();
        //设置图像是否为圆形
        rp.setRoundAsCircle(true);
        //设置圆角半径
        //rp.setCornersRadius(20);
        //分别设置左上角、右上角、左下角、右下角的圆角半径
        //rp.setCornersRadii(20,25,30,35);
        //分别设置(前2个)左上角、(3、4)右上角、(5、6)左下角、(7、8)右下角的圆角半径
        //rp.setCornersRadii(new float[]{20,25,30,35,40,45,50,55});
        //设置边框颜色及其宽度
        rp.setBorder(Color.BLACK, 10);
        //设置叠加颜色
        rp.setOverlayColor(Color.GRAY);
        //设置圆形圆角模式
        //rp.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
        //设置圆形圆角模式
        rp.setRoundingMethod(RoundingParams.RoundingMethod.OVERLAY_COLOR);

        //获取GenericDraweeHierarchy对象
        GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources())
                //设置圆形圆角参数
                .setRoundingParams(rp)
                //设置圆角半径
                //.setRoundingParams(RoundingParams.fromCornersRadius(20))
                //分别设置左上角、右上角、左下角、右下角的圆角半径
                //.setRoundingParams(RoundingParams.fromCornersRadii(20,25,30,35))
                //分别设置(前2个)左上角、(3、4)右上角、(5、6)左下角、(7、8)右下角的圆角半径
                //.setRoundingParams(RoundingParams.fromCornersRadii(new float[]{20,25,30,35,40,45,50,55}))
                //设置圆形圆角参数;RoundingParams.asCircle()是将图像设置成圆形
                //.setRoundingParams(RoundingParams.asCircle())
                //设置淡入淡出动画持续时间(单位:毫秒ms)
                .setFadeDuration(5000)
                //构建
                .build();

        //设置Hierarchy
        sdv.setHierarchy(hierarchy);

        //构建Controller
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                //设置需要下载的图片地址
                .setUri(imageUrl)
                //设置点击重试是否开启
                .setTapToRetryEnabled(true)
                //构建
                .build();

        //设置Controller
        sdv.setController(controller);
    }
 
Example #18
Source File: PhotoHolder.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
public PhotoHolder(MessagesAdapter adapter, View itemView, Peer peer) {
    super(adapter, itemView, false);
    this.context = adapter.getMessagesFragment().getActivity();

    COLOR_PENDING = ActorSDK.sharedActor().style.getConvMediaStatePendingColor();
    COLOR_SENT = ActorSDK.sharedActor().style.getConvMediaStateSentColor();
    COLOR_RECEIVED = ActorSDK.sharedActor().style.getConvMediaStateDeliveredColor();
    COLOR_READ = ActorSDK.sharedActor().style.getConvMediaStateReadColor();
    COLOR_ERROR = ActorSDK.sharedActor().style.getConvMediaStateErrorColor();

    messageBubble = (FrameLayout) itemView.findViewById(R.id.bubbleContainer);
    overlay = itemView.findViewById(R.id.photoOverlay);

    // Content
    previewView = (SimpleDraweeView) itemView.findViewById(R.id.image);
    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(context.getResources());

    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .setRoundingParams(new RoundingParams()
                    .setCornersRadius(Screen.dp(2))
                    .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY))
            .build();
    previewView.setHierarchy(hierarchy);

    animationController = new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(
                String id,
                ImageInfo imageInfo,
                Animatable anim) {
            PhotoHolder.this.anim = anim;
            playAnimation();
        }
    };

    fastThumbLoader = new FastThumbLoader(previewView);
    time = (TextView) itemView.findViewById(R.id.time);
    duration = (TextView) itemView.findViewById(R.id.duration);

    stateIcon = (TintImageView) itemView.findViewById(R.id.stateIcon);

    progressContainer = itemView.findViewById(R.id.progressBg);
    progressValue = (TextView) itemView.findViewById(R.id.progressValue);
    progressValue.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryInvColor());
    progressView = (CircularView) itemView.findViewById(R.id.progressView);
    progressView.setColor(Color.WHITE);
    progressIcon = (ImageView) itemView.findViewById(R.id.contentIcon);
    onConfigureViewHolder();
}
 
Example #19
Source File: ReactImageView.java    From react-native-GPay with MIT License 4 votes vote down vote up
private static GenericDraweeHierarchy buildHierarchy(Context context) {
  return new GenericDraweeHierarchyBuilder(context.getResources())
    .setRoundingParams(RoundingParams.fromCornersRadius(0))
    .build();
}
 
Example #20
Source File: UniversalDraweeView.java    From JianshuApp with GNU General Public License v3.0 4 votes vote down vote up
private void ensureRoundingParams() {
    if (mDraweeHierarchy.getRoundingParams() == null) {
        mDraweeHierarchy.setRoundingParams(new RoundingParams());
    }
}
 
Example #21
Source File: FrescoZoomImageView.java    From FrescoUtils with Apache License 2.0 4 votes vote down vote up
@Override
public void setCornerRadius(float radius, int overlay_color) {
    setRoundingParmas(getRoundingParams().setCornersRadius(radius).
            setRoundingMethod(RoundingParams.RoundingMethod.OVERLAY_COLOR).
            setOverlayColor(overlay_color));
}
 
Example #22
Source File: FrescoZoomImageView.java    From FrescoUtils with Apache License 2.0 4 votes vote down vote up
@Override
public void setCircle(int overlay_color) {
    setRoundingParmas(getRoundingParams().setRoundAsCircle(true).
            setRoundingMethod(RoundingParams.RoundingMethod.OVERLAY_COLOR).
            setOverlayColor(overlay_color));
}
 
Example #23
Source File: FrescoZoomImageView.java    From FrescoUtils with Apache License 2.0 4 votes vote down vote up
@Override
public void setRoundingParmas(RoundingParams roundingParmas) {
    this.getHierarchy().setRoundingParams(roundingParmas);
}
 
Example #24
Source File: FrescoImageView.java    From FrescoUtils with Apache License 2.0 4 votes vote down vote up
@Override
public void setCornerRadius(float radius, int overlay_color) {
    setRoundingParmas(getRoundingParams().setCornersRadius(radius).
            setRoundingMethod(RoundingParams.RoundingMethod.OVERLAY_COLOR).
            setOverlayColor(overlay_color));
}
 
Example #25
Source File: FrescoImageView.java    From FrescoUtils with Apache License 2.0 4 votes vote down vote up
@Override
public void setCircle(int overlay_color) {
    setRoundingParmas(getRoundingParams().setRoundAsCircle(true).
            setRoundingMethod(RoundingParams.RoundingMethod.OVERLAY_COLOR).
            setOverlayColor(overlay_color));
}
 
Example #26
Source File: FrescoImageView.java    From FrescoUtils with Apache License 2.0 4 votes vote down vote up
@Override
public void setRoundingParmas(RoundingParams roundingParmas) {
    this.getHierarchy().setRoundingParams(roundingParmas);
}
 
Example #27
Source File: FrescoPlusFetcher.java    From FrescoPlus with Apache License 2.0 4 votes vote down vote up
/**
 * @param frescoPlusView The draweeView is to display the bitmap
 * @param uri         The source uri
 * @param callback    Listening to the success or failure
 */
private void fetchImage(FrescoPlusView frescoPlusView, Uri uri, FPFetchCallback<ImageInfo> callback) {
    GenericDraweeHierarchyBuilder hierarchyBuilder = new GenericDraweeHierarchyBuilder(null);
    hierarchyBuilder.setFadeDuration(fadeDuration);
    hierarchyBuilder.setRoundingParams(RoundingParams.fromCornersRadius(radius));
    hierarchyBuilder.setActualImageScaleType(scaleType);
    if (defaultDrawable != null)
        hierarchyBuilder.setPlaceholderImage(defaultDrawable, scaleType);
    if (pressedDrawable != null)
        hierarchyBuilder.setPressedStateOverlay(pressedDrawable);
    if (retryDrawable != null)
        hierarchyBuilder.setRetryImage(retryDrawable);
    if (overlayDrawable != null)
        hierarchyBuilder.setOverlay(overlayDrawable);
    if (failureDrawable != null)
        hierarchyBuilder.setFailureImage(failureDrawable, scaleType);
    if (progressDrawable != null)
        hierarchyBuilder.setProgressBarImage(progressDrawable);
    GenericDraweeHierarchy hierarchy = hierarchyBuilder.build();

    ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);
    requestBuilder.setLowestPermittedRequestLevel(requestLevel);
    requestBuilder.setAutoRotateEnabled(autoRotateEnabled);
    if (postprocessor != null)
        requestBuilder.setPostprocessor(postprocessor);
    Priority priority = requestPriority == FrescoPriority.HIGH ? Priority.HIGH : Priority.MEDIUM;
    requestBuilder.setRequestPriority(priority);
    if (resizeWidth > 0 && resizeHeight > 0)
        requestBuilder.setResizeOptions(new ResizeOptions(resizeWidth, resizeHeight));
    ImageRequest imageRequest = requestBuilder.build();

    DraweeController draweeController = FrescoPlusCore.newDraweeControllerBuilder()
            .setOldController(frescoPlusView.getController())
            .setAutoPlayAnimations(true)
            .setRetainImageOnFailure(true)
            .setTapToRetryEnabled(true)
            .setImageRequest(imageRequest)
            .setControllerListener(FetchImageControllerListenerSupplier.newInstance(callback))
            .build();
    frescoPlusView.setHierarchy(hierarchy);
    frescoPlusView.setController(draweeController);
}
 
Example #28
Source File: FrescoController.java    From FrescoUtils with Apache License 2.0 2 votes vote down vote up
/**
 * 设置RoundingParams
 * @param roundingParmas
 */
void setRoundingParmas(RoundingParams roundingParmas);
 
Example #29
Source File: BaseFrescoImageView.java    From FrescoUtils with Apache License 2.0 2 votes vote down vote up
/**
 * 获得当前使用的RoundingParams
 */
RoundingParams getRoundingParams();
 
Example #30
Source File: FrescoUtils.java    From FrescoUtlis with Apache License 2.0 2 votes vote down vote up
/**
 * 当设置roundAsCircle为true无效时,采用这个方法,常用在gif的圆形效果上
 *
 * 或者在xml中设置:fresco:roundWithOverlayColor="@color/you_color_id"
 "you_color_id"是指你的背景色,这样也可以实现圆角、圆圈效果
 *
 *roundAsCircle的局限性:
 * 当使用BITMAP_ONLY(默认)模式时的限制:

 并非所有的图片分支部分都可以实现圆角,目前只有占位图片和实际图片可以实现圆角,我们正在努力为背景图片实现圆角功能。
 只有BitmapDrawable 和 ColorDrawable类的图片可以实现圆角。我们目前不支持包括NinePatchDrawable和 ShapeDrawable在内的其他类型图片。(无论他们是在XML或是程序中声明的)
 动画不能被圆角。
 由于Android的BitmapShader的限制,当一个图片不能覆盖全部的View的时候,边缘部分会被重复显示,而非留白。对这种情况可以使用不同的缩放类型
 (比如centerCrop)来保证图片覆盖了全部的View。 OVERLAY_COLOR模式没有上述限制,但由于这个模式使用在图片上覆盖一个纯色图层的方式来模拟圆角效果,
 因此只有在图标背景是静止的并且与图层同色的情况下才能获得较好的效果。
 * @param draweeView
 * @param bgColor 圆形遮罩的颜色,应该与背景色一致
 */
public static void setCircle( SimpleDraweeView draweeView,int bgColor){
    RoundingParams roundingParams = RoundingParams.asCircle();//这个方法在某些情况下无法成圆,比如gif
    roundingParams.setOverlayColor(bgColor);//加一层遮罩
    draweeView.getHierarchy().setRoundingParams(roundingParams);
}