Search in sources :

Example 21 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.

the class WXStickyHelper method unbindStickStyle.

public void unbindStickStyle(WXComponent component, Map<String, HashMap<String, WXComponent>> mStickyMap) {
    Scrollable scroller = component.getParentScroller();
    if (scroller == null) {
        return;
    }
    HashMap<String, WXComponent> stickyMap = mStickyMap.get(scroller.getRef());
    if (stickyMap == null) {
        return;
    }
    stickyMap.remove(component.getRef());
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) Scrollable(com.taobao.weex.ui.component.Scrollable)

Example 22 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.

the class WXStickyHelper method bindStickStyle.

public void bindStickStyle(WXComponent component, Map<String, HashMap<String, WXComponent>> mStickyMap) {
    Scrollable scroller = component.getParentScroller();
    if (scroller == null) {
        return;
    }
    HashMap<String, WXComponent> stickyMap = mStickyMap.get(scroller.getRef());
    if (stickyMap == null) {
        stickyMap = new HashMap<>();
    }
    if (stickyMap.containsKey(component.getRef())) {
        return;
    }
    stickyMap.put(component.getRef(), component);
    mStickyMap.put(scroller.getRef(), stickyMap);
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) Scrollable(com.taobao.weex.ui.component.Scrollable)

Example 23 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.

the class WXSDKInstance method setSize.

public void setSize(int width, int height) {
    if (width < 0 || height < 0 || isDestroy || !mRendered) {
        return;
    }
    float realWidth = WXViewUtils.getWebPxByWidth(width, getViewPortWidth());
    float realHeight = WXViewUtils.getWebPxByWidth(height, getViewPortWidth());
    View godView = mRenderContainer;
    if (godView != null) {
        ViewGroup.LayoutParams layoutParams = godView.getLayoutParams();
        if (layoutParams != null) {
            if (godView.getWidth() != width || godView.getHeight() != height) {
                layoutParams.width = width;
                layoutParams.height = height;
                godView.setLayoutParams(layoutParams);
            }
            JSONObject style = new JSONObject();
            WXComponent rootComponent = mRootComp;
            if (rootComponent == null) {
                return;
            }
            style.put(Constants.Name.DEFAULT_WIDTH, realWidth);
            style.put(Constants.Name.DEFAULT_HEIGHT, realHeight);
            updateRootComponentStyle(style);
        }
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) WXComponent(com.taobao.weex.ui.component.WXComponent) ViewGroup(android.view.ViewGroup) View(android.view.View) WXScrollView(com.taobao.weex.ui.view.WXScrollView) ScrollView(android.widget.ScrollView)

Example 24 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class AbstractAddElementAction method generateComponentTree.

protected WXComponent generateComponentTree(DOMActionContext context, WXDomObject dom, WXVContainer parent) {
    if (dom == null) {
        return null;
    }
    long startNanos = System.nanoTime();
    WXComponent component = WXComponentFactory.newInstance(context.getInstance(), dom, parent);
    if (component != null) {
        component.mTraceInfo.domThreadStart = dom.mDomThreadTimestamp;
        component.mTraceInfo.rootEventId = mTracingEventId;
        component.mTraceInfo.domQueueTime = mDomQueueTime;
    }
    context.registerComponent(dom.getRef(), component);
    if (component instanceof WXVContainer) {
        WXVContainer parentC = (WXVContainer) component;
        int count = dom.childCount();
        WXDomObject child = null;
        for (int i = 0; i < count; ++i) {
            child = dom.getChild(i);
            if (child != null) {
                WXComponent createdComponent = generateComponentTree(context, child, parentC);
                if (createdComponent != null) {
                    parentC.addChild(createdComponent);
                } else {
                    WXLogUtils.e("[generateComponentTree] " + getStatementName() + " create dom component failed name " + child.getType());
                    WXExceptionUtils.commitCriticalExceptionRT(context.getInstanceId(), getErrorCode(), "generateComponentTree", " create dom component failed name " + child.getType(), null);
                }
            }
        }
    }
    if (component != null) {
        component.mTraceInfo.domThreadNanos = System.nanoTime() - startNanos;
    }
    return component;
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXComponent(com.taobao.weex.ui.component.WXComponent) WXDomObject(com.taobao.weex.dom.WXDomObject)

Example 25 with WXComponent

use of com.taobao.weex.ui.component.WXComponent in project incubator-weex by apache.

the class AddElementAction method executeRender.

@Override
public void executeRender(RenderActionContext context) {
    WXComponent component = context.getComponent(mRef);
    WXSDKInstance instance = context.getInstance();
    if (instance == null || instance.getContext() == null) {
        WXLogUtils.e("instance is null or instance is destroy!");
        mErrMsg.append("instance is null or instance is destroy!");
        return;
    }
    try {
        WXVContainer parent = (WXVContainer) context.getComponent(mParentRef);
        if (parent == null || component == null) {
            mErrMsg.append("parent == null || component == null").append("parent=" + parent).append("component=" + component);
            return;
        }
        Stopwatch.tick();
        parent.addChild(component, mAddIndex);
        parent.createChildViewAt(mAddIndex);
        Stopwatch.split("createViewTree");
        component.applyLayoutAndEvent(component);
        Stopwatch.split("applyLayoutAndEvent");
        component.bindData(component);
        Stopwatch.split("bindData");
        if (WXTracing.isAvailable()) {
            String instanceId = context.getInstance().getInstanceId();
            List<Stopwatch.ProcessEvent> splits = Stopwatch.getProcessEvents();
            for (Stopwatch.ProcessEvent event : splits) {
                submitPerformance(event.fname, "X", instanceId, event.duration, event.startMillis, true);
            }
        }
        component.mTraceInfo.uiQueueTime = mUIQueueTime;
        if (component.isLazy()) {
            component.onRenderFinish(WXComponent.STATE_DOM_FINISH);
        } else {
            component.onRenderFinish(WXComponent.STATE_ALL_FINISH);
        }
    } catch (Exception e) {
        WXLogUtils.e("add component failed.", e);
        mErrMsg.append("add component failed.").append(WXLogUtils.getStackTrace(e));
    }
    instance.onElementChange();
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXSDKInstance(com.taobao.weex.WXSDKInstance) WXComponent(com.taobao.weex.ui.component.WXComponent) Stopwatch(com.taobao.weex.tracing.Stopwatch)

Aggregations

WXComponent (com.taobao.weex.ui.component.WXComponent)101 Point (android.graphics.Point)21 WXDomObject (com.taobao.weex.dom.WXDomObject)20 WXVContainer (com.taobao.weex.ui.component.WXVContainer)19 HashMap (java.util.HashMap)13 View (android.view.View)9 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)9 WXRecyclerView (com.taobao.weex.ui.view.listview.WXRecyclerView)9 Map (java.util.Map)9 Test (org.junit.Test)9 ArrayMap (android.support.v4.util.ArrayMap)8 RecyclerView (android.support.v7.widget.RecyclerView)8 JSONObject (com.alibaba.fastjson.JSONObject)8 WXSDKInstance (com.taobao.weex.WXSDKInstance)8 ComponentTest (com.taobao.weex.ui.component.ComponentTest)8 WXDivTest (com.taobao.weex.ui.component.WXDivTest)8 Scrollable (com.taobao.weex.ui.component.Scrollable)6 WXBaseRefresh (com.taobao.weex.ui.component.WXBaseRefresh)6 WXHeaderTest (com.taobao.weex.ui.component.WXHeaderTest)6 AppearanceHelper (com.taobao.weex.ui.component.AppearanceHelper)5