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