com.taobao.weex.utils.FunctionParser Java Examples

The following examples show how to use com.taobao.weex.utils.FunctionParser. 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: WXAnimationBean.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
private static Pair<Float, Float> parsePivot(@Nullable String transformOrigin,
                                             int width, int height,int viewportW) {
  if (!TextUtils.isEmpty(transformOrigin)) {
    int firstSpace = transformOrigin.indexOf(FunctionParser.SPACE);
    if (firstSpace != -1) {
      int i = firstSpace;
      for (; i < transformOrigin.length(); i++) {
        if (transformOrigin.charAt(i) != FunctionParser.SPACE) {
          break;
        }
      }
      if (i < transformOrigin.length() && transformOrigin.charAt(i) != FunctionParser.SPACE) {
        List<String> list = new ArrayList<>(2);
        list.add(transformOrigin.substring(0, firstSpace).trim());
        list.add(transformOrigin.substring(i, transformOrigin.length()).trim());
        return parsePivot(list, width, height,viewportW);
      }
    }
  }
  return null;
}
 
Example #2
Source File: WXAnimationBean.java    From weex-uikit with MIT License 6 votes vote down vote up
private static Pair<Float, Float> parsePivot(@Nullable String transformOrigin,
                                             int width, int height,int viewportW) {
  if (!TextUtils.isEmpty(transformOrigin)) {
    int firstSpace = transformOrigin.indexOf(FunctionParser.SPACE);
    if (firstSpace != -1) {
      int i = firstSpace;
      for (; i < transformOrigin.length(); i++) {
        if (transformOrigin.charAt(i) != FunctionParser.SPACE) {
          break;
        }
      }
      if (i < transformOrigin.length() && transformOrigin.charAt(i) != FunctionParser.SPACE) {
        List<String> list = new ArrayList<>(2);
        list.add(transformOrigin.substring(0, firstSpace).trim());
        list.add(transformOrigin.substring(i, transformOrigin.length()).trim());
        return parsePivot(list, width, height,viewportW);
      }
    }
  }
  return parsePivot(Arrays.asList(WXAnimationBean.Style.CENTER,
                                  WXAnimationBean.Style.CENTER), width, height,viewportW);
}
 
Example #3
Source File: WXAnimationModule.java    From weex with Apache License 2.0 6 votes vote down vote up
private static Map<String, Float> parseTransForm(@Nullable String rawTransform, final ViewGroup.LayoutParams layoutParams) {
  if (!TextUtils.isEmpty(rawTransform)) {
    FunctionParser<Float> parser = new FunctionParser<>
        (rawTransform, new FunctionParser.Mapper<Float>() {
          @Override
          public Map<String, Float> map(String functionName, List<String> raw) {
            Map<String, Float> result = new HashMap<>();
            if (raw != null && !raw.isEmpty()) {
              if (WXAnimationBean.Style.wxToAndroidMap.containsKey(functionName)) {
                result.putAll(convertParam(
                    layoutParams, WXAnimationBean.Style.wxToAndroidMap.get(functionName),
                    raw));
              }
            }
            return result;
          }

        });
    return parser.parse();
  }
  return new LinkedHashMap<>();
}