Search in sources :

Example 1 with WXImageView

use of com.taobao.weex.ui.view.WXImageView in project weex-example by KalicyZhou.

the class WXImage method initComponentHostView.

@Override
protected ImageView initComponentHostView(@NonNull Context context) {
    WXImageView view = new WXImageView(context);
    view.setScaleType(ScaleType.FIT_XY);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setCropToPadding(true);
    }
    view.holdComponent(this);
    return view;
}
Also used : WXImageView(com.taobao.weex.ui.view.WXImageView)

Example 2 with WXImageView

use of com.taobao.weex.ui.view.WXImageView 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

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