enabled border width and border color (sync diff 2)
Differential Revision: D2497575
This commit is contained in:
parent
47224bd93e
commit
2cc8acf2e3
|
@ -58,6 +58,20 @@ public class ReactImageManager extends SimpleViewManager<ReactImageView> {
|
|||
public void setSource(ReactImageView view, @Nullable String source) {
|
||||
view.setSource(source);
|
||||
}
|
||||
|
||||
@ReactProp(name = "borderColor", customType = "Color")
|
||||
public void setBorderColor(ReactImageView view, @Nullable Integer borderColor) {
|
||||
if (borderColor == null) {
|
||||
view.setBorderColor(Color.TRANSPARENT);
|
||||
} else {
|
||||
view.setBorderColor(borderColor);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactProp(name = "borderWidth")
|
||||
public void setBorderWidth(ReactImageView view, float borderWidth) {
|
||||
view.setBorderWidth(borderWidth);
|
||||
}
|
||||
|
||||
@ReactProp(name = "borderRadius")
|
||||
public void setBorderRadius(ReactImageView view, float borderRadius) {
|
||||
|
|
|
@ -22,12 +22,9 @@ import android.graphics.RectF;
|
|||
import android.graphics.Shader;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.facebook.common.util.UriUtil;
|
||||
import com.facebook.drawee.controller.AbstractDraweeControllerBuilder;
|
||||
import com.facebook.drawee.controller.ControllerListener;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import com.facebook.common.util.UriUtil;
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder;
|
||||
import com.facebook.drawee.drawable.ScalingUtils;
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||
|
@ -39,6 +36,7 @@ import com.facebook.imagepipeline.request.BasePostprocessor;
|
|||
import com.facebook.imagepipeline.request.ImageRequest;
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
||||
import com.facebook.imagepipeline.request.Postprocessor;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
|
||||
/**
|
||||
* Wrapper class around Fresco's GenericDraweeView, enabling persisting props across multiple view
|
||||
|
@ -99,6 +97,8 @@ public class ReactImageView extends GenericDraweeView {
|
|||
}
|
||||
|
||||
private @Nullable Uri mUri;
|
||||
private int mBorderColor;
|
||||
private float mBorderWidth;
|
||||
private float mBorderRadius;
|
||||
private ScalingUtils.ScaleType mScaleType;
|
||||
private boolean mIsDirty;
|
||||
|
@ -127,6 +127,16 @@ public class ReactImageView extends GenericDraweeView {
|
|||
mCallerContext = callerContext;
|
||||
}
|
||||
|
||||
public void setBorderColor(int borderColor) {
|
||||
mBorderColor = borderColor;
|
||||
mIsDirty = true;
|
||||
}
|
||||
|
||||
public void setBorderWidth(float borderWidth) {
|
||||
mBorderWidth = PixelUtil.toPixelFromDIP(borderWidth);
|
||||
mIsDirty = true;
|
||||
}
|
||||
|
||||
public void setBorderRadius(float borderRadius) {
|
||||
mBorderRadius = PixelUtil.toPixelFromDIP(borderRadius);
|
||||
mIsDirty = true;
|
||||
|
@ -180,6 +190,7 @@ public class ReactImageView extends GenericDraweeView {
|
|||
|
||||
RoundingParams roundingParams = hierarchy.getRoundingParams();
|
||||
roundingParams.setCornersRadius(hierarchyRadius);
|
||||
roundingParams.setBorder(mBorderColor, mBorderWidth);
|
||||
hierarchy.setRoundingParams(roundingParams);
|
||||
hierarchy.setFadeDuration(mImageFadeDuration >= 0
|
||||
? mImageFadeDuration
|
||||
|
|
Loading…
Reference in New Issue