use of com.taobao.weex.dom.WXStyle in project WeexErosFramework by bmfe.
the class BMPop method getAnimationHeight.
private void getAnimationHeight() {
WXDomObject wxDomObject = (WXDomObject) getDomObject();
if (wxDomObject == null)
return;
WXStyle wxStyle = wxDomObject.getStyles();
Object object = wxStyle.get("height");
if (object == null)
return;
mHeight = Integer.valueOf(object.toString());
}
use of com.taobao.weex.dom.WXStyle in project incubator-weex by apache.
the class Statements method doRenderBindingAttrsAndEvent.
/**
* render dynamic binding attrs and bind them to component node.
*/
private static void doRenderBindingAttrsAndEvent(WXComponent component, WXDomObject domObject, CellRenderContext context) {
ArrayStack stack = context.stack;
component.setWaste(false);
WXAttr attr = domObject.getAttrs();
if (attr != null && attr.getBindingAttrs() != null && attr.getBindingAttrs().size() > 0) {
ArrayMap<String, Object> bindAttrs = domObject.getAttrs().getBindingAttrs();
Map<String, Object> dynamic = renderBindingAttrs(bindAttrs, stack);
Set<Map.Entry<String, Object>> entries = dynamic.entrySet();
/**
* diff attrs, see attrs has update, remove none update attrs
*/
Iterator<Map.Entry<String, Object>> iterator = entries.iterator();
while (iterator.hasNext()) {
Map.Entry<String, Object> entry = iterator.next();
String key = entry.getKey();
Object value = entry.getValue();
Object oldValue = attr.get(key);
if (value == null) {
if (oldValue == null) {
iterator.remove();
continue;
}
} else {
if (value.equals(oldValue)) {
iterator.remove();
}
}
}
if (dynamic.size() > 0) {
if (dynamic.size() == 1 && dynamic.get(Constants.Name.SRC) != null && component instanceof WXImage) {
// for image avoid dirty layout, only update src attrs
domObject.getAttrs().put(Constants.Name.SRC, dynamic.get(Constants.Name.SRC));
} else {
// dirty layout
domObject.updateAttr(dynamic);
}
if (isMainThread()) {
component.updateProperties(dynamic);
}
dynamic.clear();
}
}
WXStyle style = domObject.getStyles();
if (style != null && style.getBindingStyle() != null) {
ArrayMap<String, Object> bindStyle = style.getBindingStyle();
Map<String, Object> dynamic = renderBindingAttrs(bindStyle, stack);
Set<Map.Entry<String, Object>> entries = dynamic.entrySet();
/**
* diff attrs, see attrs has update, remove none update attrs
*/
Iterator<Map.Entry<String, Object>> iterator = entries.iterator();
while (iterator.hasNext()) {
Map.Entry<String, Object> entry = iterator.next();
String key = entry.getKey();
Object value = entry.getValue();
Object oldValue = style.get(key);
if (value == null) {
if (oldValue == null) {
iterator.remove();
continue;
}
} else {
if (value.equals(oldValue)) {
iterator.remove();
}
}
}
if (dynamic.size() > 0) {
domObject.updateStyle(dynamic, false);
domObject.applyStyle(dynamic);
if (isMainThread()) {
component.updateProperties(dynamic);
}
}
}
WXEvent event = domObject.getEvents();
if (event == null || event.getEventBindingArgs() == null) {
return;
}
Set<Map.Entry<String, Object>> eventBindArgsEntrySet = event.getEventBindingArgs().entrySet();
for (Map.Entry<String, Object> eventBindArgsEntry : eventBindArgsEntrySet) {
List<Object> values = getBindingEventArgs(stack, eventBindArgsEntry.getValue());
if (values != null) {
event.putEventBindingArgsValue(eventBindArgsEntry.getKey(), values);
}
}
}
use of com.taobao.weex.dom.WXStyle in project incubator-weex by apache.
the class FlatGUIContext method checkComponent.
private boolean checkComponent(@NonNull WXComponent component) {
boolean ret = false;
ImmutableDomObject domObject = component.getDomObject();
if (domObject != null) {
WXStyle style = domObject.getStyles();
WXAttr attr = domObject.getAttrs();
if (style.containsKey(Name.OPACITY) || style.containsKey(Name.TRANSFORM) || style.containsKey(Name.VISIBILITY) || attr.containsKey(Name.ELEVATION) || attr.containsKey(Name.ARIA_HIDDEN) || attr.containsKey(Name.ARIA_LABEL) || attr.containsKey(WXComponent.PROP_FIXED_SIZE) || attr.containsKey(Name.DISABLED) || style.isFixed() || style.isSticky() || !style.getPesudoStyles().isEmpty() || domObject.getEvents().size() > 0) {
ret = true;
}
}
return ret;
}
Aggregations