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 WeexErosFramework by bmfe.
the class BMRich method update.
private void update() {
WXStyle styles = getDomObject().getStyles();
if (styles == null) {
styles = new WXStyle();
}
// 如果此时style为empty不会触发更新 我们在这里加入一个占位符保证style不为empty
if (styles.isEmpty()) {
styles.put("placeholder", "bm");
}
updateStyle(styles);
}
use of com.taobao.weex.dom.WXStyle in project WeexErosFramework by bmfe.
the class BMWXText method updateFontSize.
private void updateFontSize() {
if (mChangeFontSize == null) {
return;
}
WXStyle styles = null;
WXAttr attrs = null;
if (getDomObject() != null) {
styles = getDomObject().getStyles();
attrs = getDomObject().getAttrs();
if ((styles != null && "iconfont".equals(styles.get("fontFamily"))) || (attrs != null && attrs.get("changeFont") != null && !Boolean.valueOf((String) attrs.get("changeFont")))) {
return;
}
}
float scale = 0;
// 获取fontScale字段
if (attrs != null && attrs.get("fontScale") != null) {
float fontScale = Float.valueOf((String) attrs.get("fontScale"));
mCurrentScale = fontScale / mCurrentScale;
}
if (mChangeFontSize.equals(mCurrentFontSize) && mCurrentScale == 1) {
return;
}
// 获取scale字段 在标准字体下不产生变化
if (attrs != null && attrs.get("scale") != null && !(scale > 0)) {
scale = Float.valueOf((String) attrs.get("scale"));
float change = getFixedEnlarge(mChangeFontSize, scale);
float current = getFixedEnlarge(mCurrentFontSize, scale);
scale = change / current;
}
// 根据全局字体配置设置字体大小
if (!(scale > 0)) {
float current = getEnlarge(mCurrentFontSize);
float change = getEnlarge(mChangeFontSize);
scale = change / current * mCurrentScale;
}
if (getDomObject() != null && getDomObject().getStyles() != null) {
WXStyle wxStyle = getDomObject().getStyles();
Object object = wxStyle.get("fontSize");
if (object instanceof Integer) {
int fontSize = (int) object;
int changeFontSize = (int) (fontSize * (scale));
wxStyle.put("fontSize", changeFontSize);
}
// 设置lineHeight
Object lineHeight = wxStyle.get("lineHeight");
if (lineHeight instanceof Integer) {
int target = (int) lineHeight;
wxStyle.put("lineHeight", (int) (target * scale));
}
updateStyle(wxStyle);
}
mCurrentFontSize = mChangeFontSize;
}
use of com.taobao.weex.dom.WXStyle in project incubator-weex by apache.
the class WXComponent method updateBoxShadow.
protected void updateBoxShadow() {
if (!BoxShadowUtil.isBoxShadowEnabled()) {
WXLogUtils.w("BoxShadow", "box-shadow disabled");
return;
}
if (getDomObject() != null && getDomObject().getStyles() != null) {
Object boxShadow = getDomObject().getStyles().get(Constants.Name.BOX_SHADOW);
Object shadowQuality = getDomObject().getAttrs().get(Constants.Name.SHADOW_QUALITY);
if (boxShadow == null) {
return;
}
View target = mHost;
if (this instanceof WXVContainer) {
target = ((WXVContainer) this).getBoxShadowHost(false);
}
if (target == null) {
return;
}
float quality = WXUtils.getFloat(shadowQuality, 0.5f);
int viewPort = getInstance().getInstanceViewPortWidth();
String token = new StringBuilder(boxShadow.toString()).append(" / [").append(target.getMeasuredWidth()).append(",").append(target.getMeasuredHeight()).append("] / ").append(quality).toString();
if (mLastBoxShadowId != null && mLastBoxShadowId.equals(token)) {
WXLogUtils.d("BoxShadow", "box-shadow style was not modified. " + token);
return;
}
float[] radii = new float[] { 0, 0, 0, 0, 0, 0, 0, 0 };
WXStyle style = getDomObject().getStyles();
if (style != null) {
float tl = WXUtils.getFloat(style.get(Constants.Name.BORDER_TOP_LEFT_RADIUS), 0f);
radii[0] = tl;
radii[1] = tl;
float tr = WXUtils.getFloat(style.get(Constants.Name.BORDER_TOP_RIGHT_RADIUS), 0f);
radii[2] = tr;
radii[3] = tr;
float br = WXUtils.getFloat(style.get(Constants.Name.BORDER_BOTTOM_RIGHT_RADIUS), 0f);
radii[4] = br;
radii[5] = br;
float bl = WXUtils.getFloat(style.get(Constants.Name.BORDER_BOTTOM_LEFT_RADIUS), 0f);
radii[6] = bl;
radii[7] = bl;
if (style.containsKey(Constants.Name.BORDER_RADIUS)) {
float radius = WXUtils.getFloat(style.get(Constants.Name.BORDER_RADIUS), 0f);
for (int i = 0; i < radii.length; i++) {
radii[i] = radius;
}
}
}
BoxShadowUtil.setBoxShadow(target, boxShadow.toString(), radii, viewPort, quality);
mLastBoxShadowId = token;
} else {
WXLogUtils.w("Can not resolve styles");
}
}
use of com.taobao.weex.dom.WXStyle in project incubator-weex by apache.
the class WXComponent method setPseudoClassStatus.
/**
* @param clzName like ':active' or ':active:enabled'
* @param status
*/
protected void setPseudoClassStatus(String clzName, boolean status) {
WXStyle styles = getDomObject().getStyles();
Map<String, Map<String, Object>> pesudoStyles = styles.getPesudoStyles();
if (pesudoStyles == null || pesudoStyles.size() == 0) {
return;
}
Map<String, Object> resultStyles = mPesudoStatus.updateStatusAndGetUpdateStyles(clzName, status, pesudoStyles, styles.getPesudoResetStyles());
if (resultStyles != null && isRippleEnabled()) {
resultStyles.remove(Constants.Name.BACKGROUND_COLOR);
if (resultStyles.isEmpty()) {
WXLogUtils.d("PseudoClass", "skip empty pseudo styles");
return;
}
}
updateStyleByPesudo(resultStyles);
}
Aggregations