Search in sources :

Example 1 with Widget

use of com.taobao.weex.ui.flat.widget.Widget in project incubator-weex by apache.

the class WXComponent method setComponentLayoutParams.

private void setComponentLayoutParams(int realWidth, int realHeight, int realLeft, int realTop, int realRight, int realBottom, Point rawOffset) {
    if (getInstance() == null || getInstance().isDestroy()) {
        return;
    }
    FlatGUIContext UIImp = getInstance().getFlatUIContext();
    WidgetContainer ancestor;
    Widget widget;
    if (UIImp != null && (ancestor = UIImp.getFlatComponentAncestor(this)) != null) {
        if (this instanceof FlatComponent && !((FlatComponent) this).promoteToView(true)) {
            widget = ((FlatComponent) this).getOrCreateFlatWidget();
        } else {
            widget = UIImp.getAndroidViewWidget(this);
        }
        setWidgetParams(widget, UIImp, rawOffset, realWidth, realHeight, realLeft, realRight, realTop, realBottom);
    } else if (mHost != null) {
        // clear box shadow before host's size changed
        clearBoxShadow();
        if (mDomObj.isFixed()) {
            setFixedHostLayoutParams(mHost, realWidth, realHeight, realLeft, realRight, realTop, realBottom);
        } else {
            setHostLayoutParams(mHost, realWidth, realHeight, realLeft, realRight, realTop, realBottom);
        }
        mPreRealWidth = realWidth;
        mPreRealHeight = realHeight;
        mPreRealLeft = realLeft;
        mPreRealTop = realTop;
        onFinishLayout();
        // restore box shadow
        updateBoxShadow();
    }
}
Also used : FlatComponent(com.taobao.weex.ui.flat.FlatComponent) FlatGUIContext(com.taobao.weex.ui.flat.FlatGUIContext) Widget(com.taobao.weex.ui.flat.widget.Widget) AndroidViewWidget(com.taobao.weex.ui.flat.widget.AndroidViewWidget) WidgetContainer(com.taobao.weex.ui.flat.WidgetContainer)

Example 2 with Widget

use of com.taobao.weex.ui.flat.widget.Widget in project incubator-weex by apache.

the class WidgetContainer method createChildViewAt.

@Override
public void createChildViewAt(int index) {
    if (intendToBeFlatContainer()) {
        Pair<WXComponent, Integer> ret = rearrangeIndexAndGetChild(index);
        if (ret.first != null) {
            WXComponent child = ret.first;
            Widget flatChild;
            FlatGUIContext uiImp = getInstance().getFlatUIContext();
            WidgetContainer parent = uiImp.getFlatComponentAncestor(this);
            if (parent == null || uiImp.getAndroidViewWidget(this) != null) {
                parent = this;
            }
            uiImp.register(child, parent);
            if (child instanceof FlatComponent && !((FlatComponent) child).promoteToView(false)) {
                flatChild = ((FlatComponent) child).getOrCreateFlatWidget();
            } else {
                flatChild = new AndroidViewWidget(uiImp);
                uiImp.register(child, (AndroidViewWidget) flatChild);
                child.createView();
                ((AndroidViewWidget) flatChild).setContentView(child.getHostView());
                // TODO Use a sort algorithm to decide the childIndex of AndroidViewWidget
                parent.addSubView(child.getHostView(), -1);
            }
            uiImp.register(flatChild, child);
            addFlatChild(flatChild, ret.second);
        }
    } else {
        super.createChildViewAt(index);
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) Widget(com.taobao.weex.ui.flat.widget.Widget) AndroidViewWidget(com.taobao.weex.ui.flat.widget.AndroidViewWidget) AndroidViewWidget(com.taobao.weex.ui.flat.widget.AndroidViewWidget)

Example 3 with Widget

use of com.taobao.weex.ui.flat.widget.Widget in project incubator-weex by apache.

the class WXFrameLayout method dispatchDraw.

@Override
protected void dispatchDraw(Canvas canvas) {
    try {
        if (mWidgets != null) {
            canvas.save();
            canvas.translate(getPaddingLeft(), getPaddingTop());
            for (Widget widget : mWidgets) {
                widget.draw(canvas);
            }
            canvas.restore();
        } else {
            WXViewUtils.clipCanvasWithinBorderBox(this, canvas);
            super.dispatchDraw(canvas);
        }
    } catch (Throwable e) {
        WXLogUtils.e("FlatGUI Crashed when dispatchDraw", WXLogUtils.getStackTrace(e));
    }
}
Also used : Widget(com.taobao.weex.ui.flat.widget.Widget)

Aggregations

Widget (com.taobao.weex.ui.flat.widget.Widget)3 AndroidViewWidget (com.taobao.weex.ui.flat.widget.AndroidViewWidget)2 WXComponent (com.taobao.weex.ui.component.WXComponent)1 FlatComponent (com.taobao.weex.ui.flat.FlatComponent)1 FlatGUIContext (com.taobao.weex.ui.flat.FlatGUIContext)1 WidgetContainer (com.taobao.weex.ui.flat.WidgetContainer)1