use of com.taobao.weex.ui.flat.FlatComponent in project incubator-weex by apache.
the class WXComponent method setPadding.
public void setPadding(Spacing padding, Spacing border) {
int left = (int) (padding.get(Spacing.LEFT) + border.get(Spacing.LEFT));
int top = (int) (padding.get(Spacing.TOP) + border.get(Spacing.TOP));
int right = (int) (padding.get(Spacing.RIGHT) + border.get(Spacing.RIGHT));
int bottom = (int) (padding.get(Spacing.BOTTOM) + border.get(Spacing.BOTTOM));
if (this instanceof FlatComponent && !((FlatComponent) this).promoteToView(true)) {
((FlatComponent) this).getOrCreateFlatWidget().setContentBox(left, top, right, bottom);
} else if (mHost != null) {
mHost.setPadding(left, top, right, bottom);
}
}
use of com.taobao.weex.ui.flat.FlatComponent 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.FlatComponent in project incubator-weex by apache.
the class WXComponent method updateProperties.
@Deprecated
public void updateProperties(Map<String, Object> props) {
if (props == null || (mHost == null && !isVirtualComponent())) {
return;
}
for (Map.Entry<String, Object> entry : props.entrySet()) {
String key = entry.getKey();
Object param = entry.getValue();
String value = WXUtils.getString(param, null);
if (TextUtils.isEmpty(value)) {
param = convertEmptyProperty(key, value);
}
if (!setProperty(key, param)) {
if (mHolder == null) {
return;
}
Invoker invoker = mHolder.getPropertyInvoker(key);
if (invoker != null) {
try {
Type[] paramClazzs = invoker.getParameterTypes();
if (paramClazzs.length != 1) {
WXLogUtils.e("[WXComponent] setX method only one parameter:" + invoker);
return;
}
param = WXReflectionUtils.parseArgument(paramClazzs[0], param);
invoker.invoke(this, param);
} catch (Exception e) {
WXLogUtils.e("[WXComponent] updateProperties :" + "class:" + getClass() + "method:" + invoker.toString() + " function " + WXLogUtils.getStackTrace(e));
}
}
}
}
readyToRender();
if (this instanceof FlatComponent && mBackgroundDrawable != null) {
FlatComponent flatComponent = (FlatComponent) this;
if (!flatComponent.promoteToView(true) && !(flatComponent.getOrCreateFlatWidget() instanceof AndroidViewWidget)) {
flatComponent.getOrCreateFlatWidget().setBackgroundAndBorder(mBackgroundDrawable);
}
}
}
use of com.taobao.weex.ui.flat.FlatComponent in project incubator-weex by apache.
the class WXComponent method setWidgetParams.
private void setWidgetParams(Widget widget, FlatGUIContext UIImp, Point rawoffset, int width, int height, int left, int right, int top, int bottom) {
Point childOffset = new Point();
if (mParent != null) {
if (mParent instanceof FlatComponent && UIImp.getFlatComponentAncestor(mParent) != null && UIImp.getAndroidViewWidget(mParent) == null) {
childOffset.set(rawoffset.x, rawoffset.y);
} else {
childOffset.set(left, top);
}
if (mParent instanceof FlatComponent && UIImp.getFlatComponentAncestor(mParent) != null && UIImp.getAndroidViewWidget(mParent) == null) {
Point parentLayoutOffset = ((FlatComponent) mParent).getOrCreateFlatWidget().getLocInFlatContainer();
childOffset.offset(parentLayoutOffset.x, parentLayoutOffset.y);
}
ViewGroup.LayoutParams lp = mParent.getChildLayoutParams(this, mHost, width, height, left, right, top, bottom);
if (lp instanceof MarginLayoutParams) {
width = lp.width;
height = lp.height;
left = ((MarginLayoutParams) lp).leftMargin;
right = ((MarginLayoutParams) lp).rightMargin;
top = ((MarginLayoutParams) lp).topMargin;
bottom = ((MarginLayoutParams) lp).bottomMargin;
}
}
widget.setLayout(width, height, left, right, top, bottom, childOffset);
if (widget instanceof AndroidViewWidget && ((AndroidViewWidget) widget).getView() != null) {
// TODO generic method if ever possible
setHostLayoutParams((T) ((AndroidViewWidget) widget).getView(), width, height, childOffset.x, right, childOffset.y, bottom);
}
}
Aggregations