Search in sources :

Example 11 with WXComponent

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

the class WXRenderStatement method generateComponentTree.

private WXComponent generateComponentTree(WXDomObject dom, WXVContainer parent) {
    if (dom == null) {
        return null;
    }
    WXComponent component = WXComponentFactory.newInstance(mWXSDKInstance, dom, parent);
    mRegistry.put(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) {
                parentC.addChild(generateComponentTree(child, parentC));
            }
        }
    }
    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 12 with WXComponent

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

the class WXRenderStatement method updateStyle.

/**
   * @see com.taobao.weex.dom.WXDomStatement#updateStyle(String, JSONObject)
   */
void updateStyle(String ref, Map<String, Object> style) {
    WXComponent component = mRegistry.get(ref);
    if (component == null) {
        return;
    }
    component.updateProperties(style);
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 13 with WXComponent

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

the class WXRenderStatement method move.

/**
   * @see com.taobao.weex.dom.WXDomStatement#moveDom(String, String, int)
   */
void move(String ref, String parentRef, int index) {
    WXComponent component = mRegistry.get(ref);
    WXComponent newParent = mRegistry.get(parentRef);
    if (component == null || component.getParent() == null || newParent == null || !(newParent instanceof WXVContainer)) {
        return;
    }
    WXVContainer oldParent = component.getParent();
    oldParent.remove(component, false);
    ((WXVContainer) newParent).addChild(component, index);
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 14 with WXComponent

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

the class WXScrollView method procSticky.

private View procSticky(Map<String, HashMap<String, WXComponent>> mStickyMap) {
    if (mStickyMap == null) {
        return null;
    }
    HashMap<String, WXComponent> stickyMap = mStickyMap.get(mWAScroller.getRef());
    if (stickyMap == null) {
        return null;
    }
    Iterator<Entry<String, WXComponent>> iterator = stickyMap.entrySet().iterator();
    Entry<String, WXComponent> entry = null;
    WXComponent stickyData;
    while (iterator.hasNext()) {
        entry = iterator.next();
        stickyData = entry.getValue();
        getLocationOnScreen(stickyScrollerP);
        stickyData.getHostView().getLocationOnScreen(stickyViewP);
        int parentH = 0;
        if (stickyData.getParent() != null && stickyData.getParent().getRealView() != null) {
            parentH = stickyData.getParent().getRealView().getHeight();
        }
        int stickyViewH = stickyData.getHostView().getHeight();
        int stickyShowPos = stickyScrollerP[1];
        int stickyStartHidePos = -parentH + stickyScrollerP[1] + stickyViewH;
        if (stickyViewP[1] <= stickyShowPos && stickyViewP[1] >= (stickyStartHidePos - stickyViewH)) {
            mStickyOffset = stickyViewP[1] - stickyStartHidePos;
            stickyData.setStickyOffset(stickyViewP[1] - stickyScrollerP[1]);
            return stickyData.getHostView();
        } else {
            stickyData.setStickyOffset(0);
        }
    }
    return null;
}
Also used : Entry(java.util.Map.Entry) WXComponent(com.taobao.weex.ui.component.WXComponent) SuppressLint(android.annotation.SuppressLint)

Example 15 with WXComponent

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

the class BasicListComponent method onBindViewHolder.

/**
   * Bind the component of the position to the holder. Then flush the view.
   *
   * @param holder   viewHolder, which holds reference to the view
   * @param position position of component in WXListComponent
   */
@Override
public void onBindViewHolder(ListBaseViewHolder holder, int position) {
    if (holder == null)
        return;
    holder.setComponentUsing(true);
    WXComponent component = getChild(position);
    if (component == null || (component instanceof WXRefresh) || (component instanceof WXLoading) || (component.getDomObject() != null && component.getDomObject().isFixed())) {
        if (WXEnvironment.isApkDebugable()) {
            WXLogUtils.d(TAG, "Bind WXRefresh & WXLoading " + holder);
        }
        return;
    }
    if (holder.getComponent() != null && holder.getComponent() instanceof WXCell) {
        holder.getComponent().bindData(component);
    //              holder.getComponent().refreshData(component);
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) WXLoading(com.taobao.weex.ui.component.WXLoading) WXRefresh(com.taobao.weex.ui.component.WXRefresh)

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