use of com.taobao.weex.ui.flat.widget.AndroidViewWidget 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.widget.AndroidViewWidget 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);
}
}
use of com.taobao.weex.ui.flat.widget.AndroidViewWidget 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);
}
}
Aggregations