Search in sources :

Example 91 with WXComponent

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

the class GapItemDecoration method getItemOffsets.

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    int position = parent.getChildAdapterPosition(view);
    if (position < 0) {
        return;
    }
    if (view.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
        StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
        if (params.isFullSpan()) {
            return;
        }
        WXComponent component = listComponent.getChild(position);
        if (component instanceof WXCell) {
            WXCell cell = (WXCell) component;
            if (cell.isFixed() || cell.isSticky()) {
                return;
            }
            WXRecyclerDomObject recyclerDomObject = listComponent.getRecyclerDom();
            if (recyclerDomObject.getSpanOffsets() == null) {
                return;
            }
            float spanOffset = recyclerDomObject.getSpanOffsets()[params.getSpanIndex()];
            int spanOffsetPx = Math.round(WXViewUtils.getRealPxByWidth(spanOffset, recyclerDomObject.getViewPortWidth()));
            outRect.left = spanOffsetPx;
            outRect.right = -spanOffsetPx;
        }
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) WXRecyclerDomObject(com.taobao.weex.dom.WXRecyclerDomObject) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager)

Example 92 with WXComponent

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

the class ExternalLoaderComponentHolder method createInstance.

@Override
public synchronized WXComponent createInstance(WXSDKInstance instance, WXDomObject node, WXVContainer parent) throws IllegalAccessException, InvocationTargetException, InstantiationException {
    if (mClass == null) {
        mClass = mClzGetter.getExternalComponentClass(mType, instance);
    }
    ComponentCreator creator = new SimpleComponentHolder.ClazzComponentCreator(mClass);
    WXComponent component = creator.createInstance(instance, node, parent);
    component.bindHolder(this);
    return component;
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 93 with WXComponent

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

the class RenderActionContextImpl method setLayout.

/**
 * set layout information of View
 */
void setLayout(String ref, WXDomObject domObject) {
    WXComponent component = mRegistry.get(ref);
    if (component == null) {
        return;
    }
    component.setLayout(domObject);
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 94 with WXComponent

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

the class LayoutParamsProperty method set.

@Override
public void set(View object, Integer value) {
    LayoutParams layoutParams;
    if (object != null && (layoutParams = object.getLayoutParams()) != null) {
        setProperty(layoutParams, value);
        if (object instanceof IRenderResult) {
            WXComponent component = ((IRenderResult) object).getComponent();
            if (component != null) {
                component.notifyNativeSizeChanged(layoutParams.width, layoutParams.height);
            }
        }
        object.requestLayout();
    }
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) IRenderResult(com.taobao.weex.ui.view.IRenderResult) WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 95 with WXComponent

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

the class WXRecyclerTemplateList method onBindViewHolder.

@Override
public void onBindViewHolder(final TemplateViewHolder templateViewHolder, int position) {
    if (templateViewHolder == null) {
        return;
    }
    WXCell component = templateViewHolder.getTemplate();
    if (component == null) {
        return;
    }
    long start = System.currentTimeMillis();
    templateViewHolder.setHolderPosition(position);
    Object data = cellDataManager.listData.get(position);
    CellRenderState cellRenderState = cellDataManager.getRenderState(position);
    if (component.getRenderData() == data && (cellRenderState == null || !cellRenderState.isDirty())) {
        if (WXEnvironment.isOpenDebugLog() && ENABLE_TRACE_LOG) {
            WXLogUtils.d(TAG, position + " position " + getTemplateKey(position) + " onBindViewHolder none data update ");
        }
        // none update just return
        return;
    } else {
        List<WXComponent> updates = doRenderTemplate(component, position);
        Statements.doInitCompontent(updates);
        component.setRenderData(data);
        Layouts.doLayoutAsync(templateViewHolder, true);
        if (WXEnvironment.isOpenDebugLog() && ENABLE_TRACE_LOG) {
            WXLogUtils.d(TAG, position + " position " + getTemplateKey(position) + " onBindViewHolder used " + (System.currentTimeMillis() - start));
        }
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) WXDomObject(com.taobao.weex.dom.WXDomObject) JSONObject(com.alibaba.fastjson.JSONObject) WXCellDomObject(com.taobao.weex.dom.WXCellDomObject) WXRecyclerDomObject(com.taobao.weex.dom.WXRecyclerDomObject) WXCell(com.taobao.weex.ui.component.list.WXCell)

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