Search in sources :

Example 1 with ImmutableDomObject

use of com.taobao.weex.dom.ImmutableDomObject in project weex-example by KalicyZhou.

the class WXImage method updateProperties.

@Override
public void updateProperties(Map<String, Object> props) {
    super.updateProperties(props);
    WXImageView imageView;
    ImmutableDomObject imageDom;
    if ((imageDom = getDomObject()) != null && getHostView() instanceof WXImageView) {
        imageView = (WXImageView) getHostView();
        BorderDrawable borderDrawable = WXViewUtils.getBorderDrawable(getHostView());
        float[] borderRadius;
        if (borderDrawable != null) {
            RectF borderBox = new RectF(0, 0, WXDomUtils.getContentWidth(imageDom), WXDomUtils.getContentHeight(imageDom));
            borderRadius = borderDrawable.getBorderRadius(borderBox);
        } else {
            borderRadius = new float[] { 0, 0, 0, 0, 0, 0, 0, 0 };
        }
        imageView.setBorderRadius(borderRadius);
        if (imageView.getDrawable() instanceof ImageDrawable) {
            ImageDrawable imageDrawable = (ImageDrawable) imageView.getDrawable();
            float[] previousRadius = imageDrawable.getCornerRadii();
            if (!Arrays.equals(previousRadius, borderRadius)) {
                imageDrawable.setCornerRadii(borderRadius);
            }
        }
        readyToRender();
    }
}
Also used : RectF(android.graphics.RectF) ImageDrawable(com.taobao.weex.utils.ImageDrawable) BorderDrawable(com.taobao.weex.ui.view.border.BorderDrawable) ImmutableDomObject(com.taobao.weex.dom.ImmutableDomObject) WXImageView(com.taobao.weex.ui.view.WXImageView)

Aggregations

RectF (android.graphics.RectF)1 ImmutableDomObject (com.taobao.weex.dom.ImmutableDomObject)1 WXImageView (com.taobao.weex.ui.view.WXImageView)1 BorderDrawable (com.taobao.weex.ui.view.border.BorderDrawable)1 ImageDrawable (com.taobao.weex.utils.ImageDrawable)1