RN: Fix `borderRadius` for Image Background (Android)
Differential Revision: D6701597 fbshipit-source-id: 462b578c3b988c5fa7e3d25e4a6425d170ab4b62
This commit is contained in:
parent
a8f429d3a8
commit
7e9242bd1a
|
@ -30,6 +30,7 @@ import com.facebook.drawee.controller.BaseControllerListener;
|
|||
import com.facebook.drawee.controller.ControllerListener;
|
||||
import com.facebook.drawee.controller.ForwardingControllerListener;
|
||||
import com.facebook.drawee.drawable.AutoRotateDrawable;
|
||||
import com.facebook.drawee.drawable.RoundedColorDrawable;
|
||||
import com.facebook.drawee.drawable.ScalingUtils;
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||
|
@ -148,6 +149,7 @@ public class ReactImageView extends GenericDraweeView {
|
|||
private @Nullable ImageSource mImageSource;
|
||||
private @Nullable ImageSource mCachedImageSource;
|
||||
private @Nullable Drawable mLoadingImageDrawable;
|
||||
private @Nullable RoundedColorDrawable mBackgroundImageDrawable;
|
||||
private int mBorderColor;
|
||||
private int mOverlayColor;
|
||||
private float mBorderWidth;
|
||||
|
@ -238,6 +240,12 @@ public class ReactImageView extends GenericDraweeView {
|
|||
mIsDirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(int backgroundColor) {
|
||||
mBackgroundImageDrawable = new RoundedColorDrawable(backgroundColor);
|
||||
mIsDirty = true;
|
||||
}
|
||||
|
||||
public void setBorderColor(int borderColor) {
|
||||
mBorderColor = borderColor;
|
||||
mIsDirty = true;
|
||||
|
@ -377,12 +385,17 @@ public class ReactImageView extends GenericDraweeView {
|
|||
|
||||
RoundingParams roundingParams = hierarchy.getRoundingParams();
|
||||
|
||||
cornerRadii(sComputedCornerRadii);
|
||||
roundingParams.setCornersRadii(sComputedCornerRadii[0], sComputedCornerRadii[1], sComputedCornerRadii[2], sComputedCornerRadii[3]);
|
||||
|
||||
if (mBackgroundImageDrawable != null) {
|
||||
mBackgroundImageDrawable.setBorder(mBorderColor, mBorderWidth);
|
||||
mBackgroundImageDrawable.setRadii(roundingParams.getCornersRadii());
|
||||
hierarchy.setBackgroundImage(mBackgroundImageDrawable);
|
||||
}
|
||||
|
||||
if (usePostprocessorScaling) {
|
||||
roundingParams.setCornersRadius(0);
|
||||
} else {
|
||||
cornerRadii(sComputedCornerRadii);
|
||||
|
||||
roundingParams.setCornersRadii(sComputedCornerRadii[0], sComputedCornerRadii[1], sComputedCornerRadii[2], sComputedCornerRadii[3]);
|
||||
}
|
||||
|
||||
roundingParams.setBorder(mBorderColor, mBorderWidth);
|
||||
|
|
Loading…
Reference in New Issue