Java Code Examples for com.taobao.weex.dom.ImmutableDomObject#getLayoutHeight()

The following examples show how to use com.taobao.weex.dom.ImmutableDomObject#getLayoutHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WXDomUtils.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 * Get the content height of the dom.
 * @return the height of the dom that excludes top-padding, top-border-width, bottom-padding
 * and bottom-border-width.
 */
public static float getContentHeight(ImmutableDomObject domObject) {
  float rawHeight = domObject.getLayoutHeight();
  float topPadding, bottomPadding, topBorder, bottomBorder;
  Spacing padding = domObject.getPadding();
  Spacing border = domObject.getBorder();

  if (!CSSConstants.isUndefined((topPadding = padding.get(Spacing.TOP)))) {
    rawHeight -= topPadding;
  }
  if (!CSSConstants.isUndefined((bottomPadding = padding.get(Spacing.BOTTOM)))) {
    rawHeight -= bottomPadding;
  }

  if (!CSSConstants.isUndefined(topBorder = border.get(Spacing.TOP))) {
    rawHeight -= topBorder;
  }
  if (!CSSConstants.isUndefined(bottomBorder = border.get(Spacing.BOTTOM))) {
    rawHeight -= bottomBorder;
  }
  return rawHeight;
}
 
Example 2
Source File: BaseBounceView.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param refresh should be {@link WXRefreshView}
 */
public void setHeaderView(WXComponent refresh) {
    setRefreshEnable(true);
    if (swipeLayout != null) {
        WXRefreshView refreshView = swipeLayout.getHeaderView();
        if (refreshView != null) {
            ImmutableDomObject immutableDomObject = refresh.getDomObject();
            if (immutableDomObject != null) {
                int refreshHeight = (int) immutableDomObject.getLayoutHeight();
                swipeLayout.setRefreshHeight(refreshHeight);
                String colorStr = (String) immutableDomObject.getStyles().get(Constants.Name.BACKGROUND_COLOR);
                String bgColor = WXUtils.getString(colorStr, null);
                if (bgColor != null) {
                    if (!TextUtils.isEmpty(bgColor)) {
                        int colorInt = WXResourceUtils.getColor(bgColor);
                        if (!(colorInt == Color.TRANSPARENT)) {
                            swipeLayout.setRefreshBgColor(colorInt);
                        }
                    }
                }
                refreshView.setRefreshView(refresh.getHostView());
            }
        }
    }
}
 
Example 3
Source File: BaseBounceView.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param loading should be {@link WXRefreshView}
 */
public void setFooterView(WXComponent loading) {
    setLoadmoreEnable(true);
    if (swipeLayout != null) {
        WXRefreshView refreshView = swipeLayout.getFooterView();
        if (refreshView != null) {
            ImmutableDomObject immutableDomObject = loading.getDomObject();
            if (immutableDomObject != null) {
                int loadingHeight = (int) immutableDomObject.getLayoutHeight();
                swipeLayout.setLoadingHeight(loadingHeight);
                String colorStr = (String) immutableDomObject.getStyles().get(Constants.Name.BACKGROUND_COLOR);
                String bgColor = WXUtils.getString(colorStr, null);
                if (bgColor != null) {
                    if (!TextUtils.isEmpty(bgColor)) {
                        int colorInt = WXResourceUtils.getColor(bgColor);
                        if (!(colorInt == Color.TRANSPARENT)) {
                            swipeLayout.setLoadingBgColor(colorInt);
                        }
                    }
                }
                refreshView.setRefreshView(loading.getHostView());
            }
        }
    }
}
 
Example 4
Source File: WXDomUtils.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * Get the content height of the dom.
 * @return the height of the dom that excludes top-padding, top-border-width, bottom-padding
 * and bottom-border-width.
 */
public static float getContentHeight(ImmutableDomObject domObject) {
  float rawHeight = domObject.getLayoutHeight();
  float topPadding, bottomPadding, topBorder, bottomBorder;
  Spacing padding = domObject.getPadding();
  Spacing border = domObject.getBorder();

  if (!CSSConstants.isUndefined((topPadding = padding.get(Spacing.TOP)))) {
    rawHeight -= topPadding;
  }
  if (!CSSConstants.isUndefined((bottomPadding = padding.get(Spacing.BOTTOM)))) {
    rawHeight -= bottomPadding;
  }

  if (!CSSConstants.isUndefined(topBorder = border.get(Spacing.TOP))) {
    rawHeight -= topBorder;
  }
  if (!CSSConstants.isUndefined(bottomBorder = border.get(Spacing.BOTTOM))) {
    rawHeight -= bottomBorder;
  }
  return rawHeight;
}