Java Code Examples for com.taobao.weex.utils.WXResourceUtils#getColor()

The following examples show how to use com.taobao.weex.utils.WXResourceUtils#getColor() . 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: WXComponent.java    From weex-uikit with MIT License 6 votes vote down vote up
public void setBorderColor(String key, String borderColor) {
  if (!TextUtils.isEmpty(borderColor)) {
    int colorInt = WXResourceUtils.getColor(borderColor);
    if (colorInt != Integer.MIN_VALUE) {
      switch (key) {
        case Constants.Name.BORDER_COLOR:
          getOrCreateBorder().setBorderColor(Spacing.ALL, colorInt);
          break;
        case Constants.Name.BORDER_TOP_COLOR:
          getOrCreateBorder().setBorderColor(Spacing.TOP, colorInt);
          break;
        case Constants.Name.BORDER_RIGHT_COLOR:
          getOrCreateBorder().setBorderColor(Spacing.RIGHT, colorInt);
          break;
        case Constants.Name.BORDER_BOTTOM_COLOR:
          getOrCreateBorder().setBorderColor(Spacing.BOTTOM, colorInt);
          break;
        case Constants.Name.BORDER_LEFT_COLOR:
          getOrCreateBorder().setBorderColor(Spacing.LEFT, colorInt);
          break;
      }
    }
  }
}
 
Example 2
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 3
Source File: BaseBounceView.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 *
 * @param loading should be {@link WXRefreshView}
 */
public void setFooterView(WXComponent loading) {
    setLoadmoreEnable(true);
    if (swipeLayout != null) {
        if (swipeLayout.getFooterView() != null) {
            swipeLayout.setLoadingHeight((int) loading.getDomObject().getLayoutHeight());

            String colorStr = (String) loading.getDomObject().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);
                    }
                }
            }
            swipeLayout.getFooterView().setRefreshView(loading.getHostView());
        }
    }
}
 
Example 4
Source File: WXParallax.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
private void initBackgroundColor(Object obj) {
  if (obj == null)
    return;

  if (obj instanceof JSONObject) {
    mBackgroundColor = new BackgroundColorCreator();
    JSONObject object = (JSONObject) obj;

    JSONArray in = object.getJSONArray("in");
    mBackgroundColor.input = new int[in.size()];
    for (int i = 0; i < in.size(); i++) {
      mBackgroundColor.input[i] = in.getInteger(i);
    }

    JSONArray out = object.getJSONArray("out");
    mBackgroundColor.output = new int[out.size()];
    for (int i = 0; i < out.size(); i++) {
      String colorStr = out.getString(i);
      mBackgroundColor.output[i] = WXResourceUtils.getColor(colorStr);
    }
  }
}
 
Example 5
Source File: WXComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public void setBackgroundColor(String color) {
  if (!TextUtils.isEmpty(color)&& mHost!=null) {
    int colorInt = WXResourceUtils.getColor(color);
    if (!(colorInt == Color.TRANSPARENT && mBackgroundDrawable == null)){
        getOrCreateBorder().setColor(colorInt);
    }
  }
}
 
Example 6
Source File: AbstractEditComponent.java    From weex-uikit with MIT License 5 votes vote down vote up
@WXComponentProp(name = Constants.Name.COLOR)
public void setColor(String color) {
  if (getHostView() != null && !TextUtils.isEmpty(color)) {
    int colorInt = WXResourceUtils.getColor(color);
    if (colorInt != Integer.MIN_VALUE) {
      getHostView().setTextColor(colorInt);
    }
  }
}
 
Example 7
Source File: WXIndicator.java    From weex-uikit with MIT License 5 votes vote down vote up
@WXComponentProp(name = Constants.Name.ITEM_SELECTED_COLOR)
public void setItemSelectedColor(String itemSelectedColor) {
  if (!TextUtils.isEmpty(itemSelectedColor)) {
    int colorInt = WXResourceUtils.getColor(itemSelectedColor);
    if (colorInt != Integer.MIN_VALUE) {
      getHostView().setFillColor(colorInt);
      getHostView().forceLayout();
      getHostView().requestLayout();
    }
  }
}
 
Example 8
Source File: WXComponent.java    From weex with Apache License 2.0 5 votes vote down vote up
@WXComponentProp(name = WXDomPropConstant.WX_BACKGROUNDCOLOR)
public void setBackgroundColor(String color) {
  if (!TextUtils.isEmpty(color)) {
    int colorInt = WXResourceUtils.getColor(color);
    if (colorInt != Integer.MIN_VALUE) {
      getOrCreateBorder().setBackgroundColor(colorInt);
    }
  }
}
 
Example 9
Source File: WXIndicator.java    From weex with Apache License 2.0 5 votes vote down vote up
@WXComponentProp(name = "itemColor")
public void setItemColor(String itemColor) {
  if (!TextUtils.isEmpty(itemColor)) {
    int colorInt = WXResourceUtils.getColor(itemColor);
    if (colorInt != Integer.MIN_VALUE) {
      getView().setPageColor(colorInt);
      getView().forceLayout();
      getView().requestLayout();
    }
  }
}
 
Example 10
Source File: WXTextDomObject.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Record the property according to the given style
 * @param style the give style.
 */
private void updateStyleImp(Map<String, Object> style) {
  if (style != null) {
    if (style.containsKey(Constants.Name.LINES)) {
      int lines = WXStyle.getLines(style);
      if (lines > 0) {
        mNumberOfLines = lines;
      }
    }
    if (style.containsKey(Constants.Name.FONT_SIZE)) {
      mFontSize = WXStyle.getFontSize(style,getViewPortWidth());
    }
    if (style.containsKey(Constants.Name.FONT_WEIGHT)) {
      mFontWeight = WXStyle.getFontWeight(style);
    }
    if (style.containsKey(Constants.Name.FONT_STYLE)) {
      mFontStyle = WXStyle.getFontStyle(style);
    }
    if (style.containsKey(Constants.Name.COLOR)) {
      mColor = WXResourceUtils.getColor(WXStyle.getTextColor(style));
      mIsColorSet = mColor != Integer.MIN_VALUE;
    }
    if (style.containsKey(Constants.Name.TEXT_DECORATION)) {
      mTextDecoration = WXStyle.getTextDecoration(style);
    }
    if (style.containsKey(Constants.Name.FONT_FAMILY)) {
      mFontFamily = WXStyle.getFontFamily(style);
    }
    mAlignment = WXStyle.getTextAlignment(style);
    textOverflow = WXStyle.getTextOverflow(style);
    int lineHeight = WXStyle.getLineHeight(style,getViewPortWidth());
    if (lineHeight != UNSET) {
      mLineHeight = lineHeight;
    }
  }
}
 
Example 11
Source File: WXLoadingIndicator.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@WXComponentProp(name = Constants.Name.COLOR)
public void setColor(String color) {
    if (color != null && !color.equals("")) {
        int parseColor = WXResourceUtils.getColor(color, Color.RED);
        getHostView().setColorSchemeColors(parseColor);
    }
}
 
Example 12
Source File: WXComponent.java    From weex-uikit with MIT License 5 votes vote down vote up
public void setBackgroundColor(String color) {
  if (!TextUtils.isEmpty(color)&& mHost!=null) {
    int colorInt = WXResourceUtils.getColor(color);
    if (!(colorInt == Color.TRANSPARENT && mBackgroundDrawable == null)){
        getOrCreateBorder().setColor(colorInt);
    }
  }
}
 
Example 13
Source File: AbstractEditComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@WXComponentProp(name = Constants.Name.COLOR)
public void setColor(String color) {
  if (getHostView() != null && !TextUtils.isEmpty(color)) {
    int colorInt = WXResourceUtils.getColor(color);
    if (colorInt != Integer.MIN_VALUE) {
      getHostView().setTextColor(colorInt);
    }
  }
}
 
Example 14
Source File: WXInput.java    From weex with Apache License 2.0 5 votes vote down vote up
@WXComponentProp(name = WXDomPropConstant.WX_INPUT_PLACEHOLDER_COLOR)
public void setPlaceholderColor(String color) {
  if (mHost != null && !TextUtils.isEmpty(color)) {
    int colorInt = WXResourceUtils.getColor(color);
    if (colorInt != Integer.MIN_VALUE) {
      ((WXEditText) mHost).setHintTextColor(colorInt);
    }
  }
}
 
Example 15
Source File: WXIndicator.java    From weex with Apache License 2.0 5 votes vote down vote up
@WXComponentProp(name = "itemSelectedColor")
public void setItemSelectedColor(String itemSelectedColor) {
  if (!TextUtils.isEmpty(itemSelectedColor)) {
    int colorInt = WXResourceUtils.getColor(itemSelectedColor);
    if (colorInt != Integer.MIN_VALUE) {
      getView().setFillColor(colorInt);
      getView().forceLayout();
      getView().requestLayout();
    }
  }
}
 
Example 16
Source File: WXIndicator.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@WXComponentProp(name = Constants.Name.ITEM_SELECTED_COLOR)
public void setItemSelectedColor(String itemSelectedColor) {
  if (!TextUtils.isEmpty(itemSelectedColor)) {
    int colorInt = WXResourceUtils.getColor(itemSelectedColor);
    if (colorInt != Integer.MIN_VALUE) {
      getHostView().setFillColor(colorInt);
      getHostView().forceLayout();
      getHostView().requestLayout();
    }
  }
}
 
Example 17
Source File: WXIndicator.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@WXComponentProp(name = Constants.Name.ITEM_COLOR)
public void setItemColor(String itemColor) {
  if (!TextUtils.isEmpty(itemColor)) {
    int colorInt = WXResourceUtils.getColor(itemColor);
    if (colorInt != Integer.MIN_VALUE) {
      getHostView().setPageColor(colorInt);
      getHostView().forceLayout();
      getHostView().requestLayout();
    }
  }
}
 
Example 18
Source File: WXShapeFeature.java    From weex with Apache License 2.0 5 votes vote down vote up
public WXShapeFeature(Context context, View view, WXDomObject dom) {
  if (dom == null) {
    return;
  }
  mDom = dom;
  int strokeColor = Color.GRAY;
  mHost = view;

  int type = RoundRectShape;
  initCornerRadius();
  setShape(type);
  mStrokePaint = new Paint();

  mStrokePaint.setStyle(Paint.Style.STROKE);
  mStrokePaint.setAntiAlias(true);
  if (mDom.style != null) {
    String realBgColor = mDom.style.getBorderColor();
    if (!TextUtils.isEmpty(realBgColor)) {
      strokeColor = WXResourceUtils.getColor(realBgColor);
    }
    if (strokeColor == -1) {
      strokeColor = Color.GRAY;
    }
    mStrokeWidth = mDom.style.getBorderWidth();
    if (!WXUtils.isUndefined(mStrokeWidth) && mStrokeWidth > 0) {
      mStrokeEnable = true;
      mStrokeWidth = WXViewUtils.getRealPxByWidth(mStrokeWidth);
      mStrokePaint.setStrokeWidth(mStrokeWidth);
    }
  }

  mStrokePaint.setColor(strokeColor);

  mStrokePath = new Path();
  mRectF = new RectF();
}
 
Example 19
Source File: WXTextDomObject.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
/**
 * Record the property according to the given style
 * @param style the give style.
 */
private void updateStyleImp(Map<String, Object> style) {
  if (style != null) {
    if (style.containsKey(Constants.Name.LINES)) {
      int lines = WXStyle.getLines(style);
      mNumberOfLines = lines > 0 ? lines : UNSET;
    }
    if (style.containsKey(Constants.Name.FONT_SIZE)) {
      mFontSize = WXStyle.getFontSize(style,getViewPortWidth());
    }
    if (style.containsKey(Constants.Name.FONT_WEIGHT)) {
      mFontWeight = WXStyle.getFontWeight(style);
    }
    if (style.containsKey(Constants.Name.FONT_STYLE)) {
      mFontStyle = WXStyle.getFontStyle(style);
    }
    if (style.containsKey(Constants.Name.COLOR)) {
      mColor = WXResourceUtils.getColor(WXStyle.getTextColor(style));
      mIsColorSet = mColor != Integer.MIN_VALUE;
    }
    if (style.containsKey(Constants.Name.TEXT_DECORATION)) {
      mTextDecoration = WXStyle.getTextDecoration(style);
    }
    if (style.containsKey(Constants.Name.FONT_FAMILY)) {
      mFontFamily = WXStyle.getFontFamily(style);
    }
    mAlignment = WXStyle.getTextAlignment(style);
    textOverflow = WXStyle.getTextOverflow(style);
    int lineHeight = WXStyle.getLineHeight(style,getViewPortWidth());
    if (lineHeight != UNSET) {
      mLineHeight = lineHeight;
    }
  }
}
 
Example 20
Source File: WXPickersModule.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private int getColor(Map<String, Object> options, String key, int defValue) {
    Object value = getOption(options, key, null);
    if (value == null) {
        return defValue;
    }
    return WXResourceUtils.getColor(value.toString(), defValue);
}