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;
}
}
}
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;
}
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);
}
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();
}
}
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));
}
}
}
Aggregations