com.taobao.weex.dom.ImmutableDomObject Java Examples
The following examples show how to use
com.taobao.weex.dom.ImmutableDomObject.
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 |
/** * Get the content width of the dom. * @return the width of the dom that excludes left-padding, left-border-width, * right-border-width and right-padding. */ public static float getContentWidth(ImmutableDomObject domObject) { float rawWidth = domObject.getLayoutWidth(); float leftPadding, rightPadding, leftBorder, rightBorder; Spacing padding = domObject.getPadding(); Spacing border = domObject.getBorder(); if (!CSSConstants.isUndefined((leftPadding = padding.get(Spacing.LEFT)))) { rawWidth -= leftPadding; } if (!CSSConstants.isUndefined((rightPadding = padding.get(Spacing.RIGHT)))) { rawWidth -= rightPadding; } if (!CSSConstants.isUndefined(leftBorder = border.get(Spacing.LEFT))) { rawWidth -= leftBorder; } if (!CSSConstants.isUndefined(rightBorder = border.get(Spacing.RIGHT))) { rawWidth -= rightBorder; } return rawWidth; }
Example #2
Source File: WXDomUtils.java From ucar-weex-core with Apache License 2.0 | 6 votes |
/** * 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 #3
Source File: BaseBounceView.java From ucar-weex-core with Apache License 2.0 | 6 votes |
/** * * @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 #4
Source File: BaseBounceView.java From ucar-weex-core with Apache License 2.0 | 6 votes |
/** * * @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 #5
Source File: WXA.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override protected void onHostViewInitialized(WXFrameLayout host) { super.onHostViewInitialized(host); addClickListener(new OnClickListener() { @Override public void onHostViewClick() { String href; ImmutableDomObject domObject = getDomObject(); if (domObject != null) { WXAttr attr = domObject.getAttrs(); if (attr !=null && (href = (String)attr.get("href")) != null) { ATagUtil.onClick(null, getInstanceId(), href); } } else { WXLogUtils.d("WXA", "Property href is empty."); } } }); }
Example #6
Source File: WXDomUtils.java From weex-uikit with MIT License | 6 votes |
/** * 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 #7
Source File: WXDomUtils.java From weex-uikit with MIT License | 6 votes |
/** * Get the content width of the dom. * @return the width of the dom that excludes left-padding, left-border-width, * right-border-width and right-padding. */ public static float getContentWidth(ImmutableDomObject domObject) { float rawWidth = domObject.getLayoutWidth(); float leftPadding, rightPadding, leftBorder, rightBorder; Spacing padding = domObject.getPadding(); Spacing border = domObject.getBorder(); if (!CSSConstants.isUndefined((leftPadding = padding.get(Spacing.LEFT)))) { rawWidth -= leftPadding; } if (!CSSConstants.isUndefined((rightPadding = padding.get(Spacing.RIGHT)))) { rawWidth -= rightPadding; } if (!CSSConstants.isUndefined(leftBorder = border.get(Spacing.LEFT))) { rawWidth -= leftBorder; } if (!CSSConstants.isUndefined(rightBorder = border.get(Spacing.RIGHT))) { rawWidth -= rightBorder; } return rawWidth; }
Example #8
Source File: BasicListComponent.java From ucar-weex-core with Apache License 2.0 | 6 votes |
private String getTriggerType(@Nullable ImmutableDomObject domObject) { String triggerType = DEFAULT_TRIGGER_TYPE; if (domObject == null) { return triggerType; } triggerType = WXUtils.getString(domObject.getAttrs().get(DRAG_TRIGGER_TYPE), DEFAULT_TRIGGER_TYPE); if (!DragTriggerType.LONG_PRESS.equals(triggerType) && !DragTriggerType.PAN.equals(triggerType)) { triggerType = DEFAULT_TRIGGER_TYPE; } if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "trigger type is " + triggerType); } return triggerType; }
Example #9
Source File: WXComponent.java From ucar-weex-core with Apache License 2.0 | 6 votes |
public void destroy() { ComponentObserver observer; if ((observer = getInstance().getComponentObserver()) != null) { observer.onPreDestory(this); } if (WXEnvironment.isApkDebugable() && !WXUtils.isUiThread()) { throw new WXRuntimeException("[WXComponent] destroy can only be called in main thread"); } if(mHost!= null && mHost.getLayerType()==View.LAYER_TYPE_HARDWARE && isLayerTypeEnabled()) { mHost.setLayerType(View.LAYER_TYPE_NONE, null); } removeAllEvent(); removeStickyStyle(); View view; if(mDomObj.isFixed() && (view = getHostView()) != null){ getInstance().removeFixedView(view); } mDomObj = ImmutableDomObject.DESTROYED; mIsDestroyed = true; }
Example #10
Source File: WXLoading.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override public void onPullingUp(float dy, int pullOutDistance, float viewHeight) { ImmutableDomObject domObject = getDomObject(); if (domObject != null && domObject.getEvents().contains(Constants.Event.ONPULLING_UP)) { Map<String, Object> data = new HashMap<>(); data.put(Constants.Name.DISTANCE_Y, dy); data.put(Constants.Name.PULLING_DISTANCE, pullOutDistance); data.put(Constants.Name.VIEW_HEIGHT, viewHeight); fireEvent(Constants.Event.ONPULLING_UP, data); } }
Example #11
Source File: WXLoading.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override public void onLoading() { ImmutableDomObject domObject = getDomObject(); if (domObject != null && domObject.getEvents().contains(Constants.Event.ONLOADING)) { fireEvent(Constants.Event.ONLOADING); } }
Example #12
Source File: BasicListComponent.java From ucar-weex-core with Apache License 2.0 | 5 votes |
private boolean isDragExcluded(@Nullable ImmutableDomObject domObject) { if (domObject == null) { return DEFAULT_EXCLUDED; } WXAttr cellAttrs = domObject.getAttrs(); return WXUtils.getBoolean(cellAttrs.get(EXCLUDED), DEFAULT_EXCLUDED); }
Example #13
Source File: BasicListComponent.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Nullable private WXComponent findComponentByAnchorName(@NonNull WXComponent root, @NonNull String anchorName) { long start = 0; if (WXEnvironment.isApkDebugable()) { start = System.currentTimeMillis(); } Deque<WXComponent> deque = new ArrayDeque<>(); deque.add(root); while (!deque.isEmpty()) { WXComponent curComponent = deque.removeFirst(); ImmutableDomObject object = curComponent.getDomObject(); if (object != null) { String isAnchorSet = WXUtils.getString(object.getAttrs().get(anchorName), null); //hit if (isAnchorSet != null && isAnchorSet.equals("true")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d("dragPerf", "findComponentByAnchorName time: " + (System.currentTimeMillis() - start) + "ms"); } return curComponent; } } if (curComponent instanceof WXVContainer) { WXVContainer container = (WXVContainer) curComponent; for (int i = 0, len = container.childCount(); i < len; i++) { WXComponent child = container.getChild(i); deque.add(child); } } } if (WXEnvironment.isApkDebugable()) { WXLogUtils.d("dragPerf", "findComponentByAnchorName elapsed time: " + (System.currentTimeMillis() - start) + "ms"); } return null; }
Example #14
Source File: BasicListComponent.java From ucar-weex-core with Apache License 2.0 | 5 votes |
/** * To determine whether an animation is needed * @param child * @return */ private boolean isRemoveAnimation(WXComponent child) { ImmutableDomObject domObject = child.getDomObject(); if (domObject != null) { Object attr = domObject.getAttrs().get(Constants.Name.DELETE_CELL_ANIMATION); if (Constants.Value.DEFAULT.equals(attr)) { return true; } } return false; }
Example #15
Source File: BasicListComponent.java From ucar-weex-core with Apache License 2.0 | 5 votes |
/** * Determine if the component needs to be fixed at the time of insertion * @param child Need to insert the component * @return fixed=true */ private boolean isKeepScrollPosition(WXComponent child,int index) { ImmutableDomObject domObject = child.getDomObject(); if (domObject != null) { Object attr = domObject.getAttrs().get(Constants.Name.KEEP_SCROLL_POSITION); if (WXUtils.getBoolean(attr, false) && index <= getChildCount() && index>-1) { return true; } } return false; }
Example #16
Source File: BasicListComponent.java From ucar-weex-core with Apache License 2.0 | 5 votes |
/** * To determine whether an animation is needed * @param child * @return */ private boolean isAddAnimation(WXComponent child) { ImmutableDomObject domObject = child.getDomObject(); if (domObject != null) { Object attr = domObject.getAttrs().get(Constants.Name.INSERT_CELL_ANIMATION); if (Constants.Value.DEFAULT.equals(attr)) { return true; } } return false; }
Example #17
Source File: WXRefresh.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override public void onRefresh() { if(isDestoryed()){ return; } ImmutableDomObject dom; if ((dom = getDomObject())!= null && dom.getEvents().contains(Constants.Event.ONREFRESH)) { fireEvent(Constants.Event.ONREFRESH); } }
Example #18
Source File: WXComponent.java From weex-uikit with MIT License | 4 votes |
public ImmutableDomObject getDomObject() { return mDomObj; }
Example #19
Source File: WXComponent.java From weex-uikit with MIT License | 4 votes |
/** * layout view */ public final void setLayout(ImmutableDomObject domObject) { if ( domObject == null || TextUtils.isEmpty(mCurrentRef)) { return; } boolean nullParent = mParent == null;//parent is nullable mDomObj = domObject; //offset by sibling int siblingOffset = nullParent?0:mParent.getChildrenLayoutTopOffset(); Spacing parentPadding = (nullParent?new Spacing():mParent.getDomObject().getPadding()); Spacing parentBorder = (nullParent?new Spacing():mParent.getDomObject().getBorder()); Spacing margin = mDomObj.getMargin(); int realWidth = (int) mDomObj.getLayoutWidth(); int realHeight = (int) mDomObj.getLayoutHeight(); int realLeft = (int) (mDomObj.getLayoutX() - parentPadding.get(Spacing.LEFT) - parentBorder.get(Spacing.LEFT)); int realTop = (int) (mDomObj.getLayoutY() - parentPadding.get(Spacing.TOP) - parentBorder.get(Spacing.TOP)) + siblingOffset; int realRight = (int) margin.get(Spacing.RIGHT); int realBottom = (int) margin.get(Spacing.BOTTOM); if (mPreRealWidth == realWidth && mPreRealHeight == realHeight && mPreRealLeft == realLeft && mPreRealTop == realTop) { return; } mAbsoluteY = (int) (nullParent?0:mParent.getAbsoluteY() + mDomObj.getLayoutY()); mAbsoluteX = (int) (nullParent?0:mParent.getAbsoluteX() + mDomObj.getLayoutX()); //calculate first screen time if (!mInstance.mEnd &&!(mHost instanceof ViewGroup) && mAbsoluteY+realHeight > mInstance.getWeexHeight()+1) { mInstance.firstScreenRenderFinished(); } if (mHost == null) { return; } MeasureOutput measureOutput = measure(realWidth, realHeight); realWidth = measureOutput.width; realHeight = measureOutput.height; //fixed style 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(); }
Example #20
Source File: WXSvgLinearGradient.java From Svg-for-Apache-Weex with Apache License 2.0 | 4 votes |
@Override protected void saveDefinition() { if (mName != null) { ArrayList points = new ArrayList<String>(); points.add(mX1); points.add(mY1); points.add(mX2); points.add(mY2); ArrayList<Integer> stopColors = new ArrayList<>(); ArrayList<Float> stops = new ArrayList<>(); for (int i = 0; i < childCount(); i++) { if (getChild(i) instanceof WXSvgStop) { ImmutableDomObject domObject = getChild(i).getDomObject(); int color = Color.TRANSPARENT; if (!TextUtils.isEmpty((CharSequence) domObject.getAttrs().get("stopColor"))) { color = SvgParser.parseColor((String) domObject.getAttrs().get("stopColor")); } if (!TextUtils.isEmpty((CharSequence) domObject.getStyles().get("stopColor"))) { color = SvgParser.parseColor((String) domObject.getStyles().get("stopColor")); } float offset = ParserHelper.fromPercentageToFloat( (String) domObject.getAttrs().get("offset"), 1, 0, 1); stops.add(offset); stopColors.add(color); } } int[] colors = new int[stopColors.size()]; for (int i = 0; i < colors.length; i++) { colors[i] = stopColors.get(i); } float[] positions = new float[stops.size()]; for (int i = 0; i < positions.length; i++) { positions[i] = stops.get(i); } SvgBrush brush = new SvgBrush(SvgBrush.GradientType .LINEAR_GRADIENT, points, positions, colors); getSvgComponent().defineBrush(brush, mName); } }
Example #21
Source File: WXComponent.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public ImmutableDomObject getDomObject() { return mDomObj; }
Example #22
Source File: WXComponent.java From ucar-weex-core with Apache License 2.0 | 4 votes |
/** * layout view */ public final void setLayout(ImmutableDomObject domObject) { if ( domObject == null || TextUtils.isEmpty(mCurrentRef)) { return; } boolean nullParent = mParent == null;//parent is nullable mDomObj = domObject; //offset by sibling int siblingOffset = nullParent?0:mParent.getChildrenLayoutTopOffset(); Spacing parentPadding = (nullParent?new Spacing():mParent.getDomObject().getPadding()); Spacing parentBorder = (nullParent?new Spacing():mParent.getDomObject().getBorder()); Spacing margin = mDomObj.getMargin(); int realWidth = (int) mDomObj.getLayoutWidth(); int realHeight = (int) mDomObj.getLayoutHeight(); int realLeft = (int) (mDomObj.getLayoutX() - parentPadding.get(Spacing.LEFT) - parentBorder.get(Spacing.LEFT)); int realTop = (int) (mDomObj.getLayoutY() - parentPadding.get(Spacing.TOP) - parentBorder.get(Spacing.TOP)) + siblingOffset; int realRight = (int) margin.get(Spacing.RIGHT); int realBottom = (int) margin.get(Spacing.BOTTOM); if (mPreRealWidth == realWidth && mPreRealHeight == realHeight && mPreRealLeft == realLeft && mPreRealTop == realTop) { return; } mAbsoluteY = (int) (nullParent?0:mParent.getAbsoluteY() + mDomObj.getLayoutY()); mAbsoluteX = (int) (nullParent?0:mParent.getAbsoluteX() + mDomObj.getLayoutX()); //calculate first screen time if (!mInstance.mEnd &&!(mHost instanceof ViewGroup) && mAbsoluteY+realHeight > mInstance.getWeexHeight()+1) { mInstance.firstScreenRenderFinished(); } if (mHost == null) { return; } MeasureOutput measureOutput = measure(realWidth, realHeight); realWidth = measureOutput.width; realHeight = measureOutput.height; //fixed style 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(); }
Example #23
Source File: WXComponent.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public void updateAttrs(WXComponent component){ ImmutableDomObject domObject = component.getDomObject(); if(domObject !=null){ updateProperties(domObject.getAttrs()); } }
Example #24
Source File: WXComponent.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public void updateStyle(WXComponent component){ ImmutableDomObject domObject = component.getDomObject(); if(domObject !=null){ updateProperties(domObject.getStyles()); } }
Example #25
Source File: WXSvgRadialGradient.java From Svg-for-Apache-Weex with Apache License 2.0 | 4 votes |
@Override protected void saveDefinition() { if (mName != null) { ArrayList<String> points = new ArrayList<String>(); points.add(mFx); points.add(mFy); points.add(mRx); points.add(mRy); points.add(mCx); points.add(mCy); ArrayList<Integer> stopColors = new ArrayList<>(); ArrayList<Float> stops = new ArrayList<>(); for (int i = 0; i < childCount(); i++) { if (getChild(i) instanceof WXSvgStop) { ImmutableDomObject domObject = getChild(i).getDomObject(); int color = Color.TRANSPARENT; String stopColor = (String) domObject.getAttrs().get("stopColor"); if (!TextUtils.isEmpty(stopColor) && stopColor.length() > 0) { Log.v("WXSvgRadialGradient", "stop color is " + stopColor); color = SvgParser.parseColor(stopColor); } stopColor = (String) domObject.getStyles().get("stopColor"); if (!TextUtils.isEmpty(stopColor) && stopColor.length() > 0) { color = SvgParser.parseColor(stopColor); } float offset = ParserHelper.fromPercentageToFloat( (String) domObject.getAttrs().get("offset"), 1, 0, 1); stops.add(offset); stopColors.add(color); } } int[] colors = new int[stopColors.size()]; for (int i = 0; i < colors.length; i++) { colors[i] = stopColors.get(i); } float[] positions = new float[stops.size()]; for (int i = 0; i < positions.length; i++) { positions[i] = stops.get(i); } SvgBrush brush = new SvgBrush(SvgBrush.GradientType .RADIAL_GRADIENT, points, positions, colors); getSvgComponent().defineBrush(brush, mName); } }