Java Code Examples for com.taobao.weex.utils.WXUtils#getString()

The following examples show how to use com.taobao.weex.utils.WXUtils#getString() . 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: 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 2
Source File: WXImage.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
  protected boolean setProperty(String key, Object param) {
    switch (key) {
      case Constants.Name.RESIZE_MODE:
        String resize_mode = WXUtils.getString(param, null);
        if (resize_mode != null)
          setResizeMode(resize_mode);
        return true;
      case Constants.Name.RESIZE:
        String resize = WXUtils.getString(param, null);
        if (resize != null)
          setResize(resize);
        return true;
      case Constants.Name.SRC:
        String src = WXUtils.getString(param, null);
        if (src != null)
          setSrc(src);
        return true;
      case Constants.Name.IMAGE_QUALITY:
        return true;
      case Constants.Name.FILTER:
        return true;
    }
  return super.setProperty(key, param);
}
 
Example 3
Source File: WXWeb.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
    switch (key) {
        case Constants.Name.SHOW_LOADING:
            Boolean result = WXUtils.getBoolean(param,null);
            if (result != null)
                setShowLoading(result);
            return true;
        case Constants.Name.SRC:
            String src = WXUtils.getString(param,null);
            if (src != null)
                setUrl(src);
            return true;
    }
    return super.setProperty(key,param);
}
 
Example 4
Source File: WXSliderNeighbor.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
    String input;
    switch (key) {
        case NEIGHBOR_SCALE:
            input = WXUtils.getString(param, null);
            if (input != null) {
                setNeighborScale(input);
            }
            return true;
        case NEIGHBOR_ALPHA:
            input = WXUtils.getString(param, null);
            if (input != null) {
                setNeighborAlpha(input);
            }
            return true;
        case NEIGHBOR_SPACE:
            input = WXUtils.getString(param, null);
            if (input != null) {
                setNeighborSpace(input);
            }
            return true;
    }
    return super.setProperty(key, param);
}
 
Example 5
Source File: BaseBounceView.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 *
 * @param refresh should be {@link WXRefreshView}
 */
public void setHeaderView(WXComponent refresh) {
    setRefreshEnable(true);
    if (swipeLayout != null) {
        if (swipeLayout.getHeaderView() != null) {
            swipeLayout.setRefreshHeight((int) refresh.getDomObject().getLayoutHeight());

            String colorStr = (String) refresh.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.setRefreshBgColor(colorInt);
                    }
                }
            }
            swipeLayout.getHeaderView().setRefreshView(refresh.getHostView());
        }
    }
}
 
Example 6
Source File: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
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 7
Source File: WXIndicator.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
  switch (key) {
    case Constants.Name.ITEM_COLOR:
      String item_color = WXUtils.getString(param,null);
      if (item_color != null)
        setItemColor(item_color);
      return true;
    case Constants.Name.ITEM_SELECTED_COLOR:
      String selected_color = WXUtils.getString(param,null);
      if (selected_color != null)
        setItemSelectedColor(selected_color);
      return true;
    case Constants.Name.ITEM_SIZE:
      Integer item_size = WXUtils.getInteger(param,null);
      if (item_size != null)
        setItemSize(item_size);
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 8
Source File: WXVideo.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
  switch (key) {
    case Constants.Name.SRC:
      String src = WXUtils.getString(param, null);
      if (src != null) {
        setSrc(src);
      }
      return true;
    case Constants.Name.AUTO_PLAY:
      Boolean result = WXUtils.getBoolean(param, null);
      if (result != null) {
        setAutoPlay(result);
      }
      return true;
    case Constants.Name.PLAY_STATUS:
      String status = WXUtils.getString(param, null);
      if (status != null) {
        setPlaystatus(status);
      }
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 9
Source File: WXVideo.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
  switch (key) {
    case Constants.Name.SRC:
      String src = WXUtils.getString(param, null);
      if (src != null) {
        setSrc(src);
      }
      return true;
    case Constants.Name.AUTO_PLAY:
      Boolean result = WXUtils.getBoolean(param, null);
      if (result != null) {
        setAutoPlay(result);
      }
      return true;
    case Constants.Name.PLAY_STATUS:
      String status = WXUtils.getString(param, null);
      if (status != null) {
        setPlaystatus(status);
      }
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 10
Source File: WXWeb.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
    switch (key) {
        case Constants.Name.SHOW_LOADING:
            Boolean result = WXUtils.getBoolean(param,null);
            if (result != null)
                setShowLoading(result);
            return true;
        case Constants.Name.SRC:
            String src = WXUtils.getString(param,null);
            if (src != null)
                setUrl(src);
            return true;
    }
    return super.setProperty(key,param);
}
 
Example 11
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 12
Source File: WXIndicator.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
  switch (key) {
    case Constants.Name.ITEM_COLOR:
      String item_color = WXUtils.getString(param,null);
      if (item_color != null)
        setItemColor(item_color);
      return true;
    case Constants.Name.ITEM_SELECTED_COLOR:
      String selected_color = WXUtils.getString(param,null);
      if (selected_color != null)
        setItemSelectedColor(selected_color);
      return true;
    case Constants.Name.ITEM_SIZE:
      Integer item_size = WXUtils.getInteger(param,null);
      if (item_size != null)
        setItemSize(item_size);
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 13
Source File: WXLoadingIndicator.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
    switch (key) {
        case Constants.Name.COLOR:
            String color = WXUtils.getString(param,null);
            if (color != null)
                setColor(color);
            return true;
    }
    return super.setProperty(key, param);
}
 
Example 14
Source File: WXRefresh.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
  switch (key) {
    case Constants.Name.DISPLAY:
      String display = WXUtils.getString(param,null);
      if (display != null)
        setDisplay(display);
      return true;
  }
  return super.setProperty(key,param);
}
 
Example 15
Source File: WXRefresh.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
  switch (key) {
    case Constants.Name.DISPLAY:
      String display = WXUtils.getString(param,null);
      if (display != null)
        setDisplay(display);
      return true;
  }
  return super.setProperty(key,param);
}
 
Example 16
Source File: WXLoadingIndicator.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
    switch (key) {
        case Constants.Name.COLOR:
            String color = WXUtils.getString(param,null);
            if (color != null)
                setColor(color);
            return true;
    }
    return super.setProperty(key, param);
}
 
Example 17
Source File: WXLoading.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
  switch (key) {
    case Constants.Name.DISPLAY:
      String display = WXUtils.getString(param,null);
      if (display != null)
        setDisplay(display);
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 18
Source File: WXImage.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
  protected boolean setProperty(String key, Object param) {
    switch (key) {
      case Constants.Name.RESIZE_MODE:
        String resize_mode = WXUtils.getString(param, null);
        if (resize_mode != null)
          setResizeMode(resize_mode);
        return true;
      case Constants.Name.RESIZE:
        String resize = WXUtils.getString(param, null);
        if (resize != null)
          setResize(resize);
        return true;
      case Constants.Name.SRC:
        String src = WXUtils.getString(param, null);
        if (src != null)
          setSrc(src);
        return true;
      case Constants.Name.IMAGE_QUALITY:
        return true;
      case Constants.Name.FILTER:
        int blurRadius = 0;
        if(param != null && param instanceof String) {
          blurRadius = parseBlurRadius((String)param);
        }
        if(!TextUtils.isEmpty(this.mSrc)) {
          setBlurRadius(this.mSrc,blurRadius);
        }
        return true;
    }
  return super.setProperty(key, param);
}
 
Example 19
Source File: AbstractEditComponent.java    From weex-uikit with MIT License 4 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
  switch (key) {
    case Constants.Name.PLACEHOLDER:
      String placeholder = WXUtils.getString(param,null);
      if (placeholder != null)
        setPlaceholder(placeholder);
      return true;
    case Constants.Name.PLACEHOLDER_COLOR:
      String placeholder_color = WXUtils.getString(param,null);
      if (placeholder_color != null)
        setPlaceholderColor(placeholder_color);
      return true;
    case Constants.Name.TYPE:
      String input_type = WXUtils.getString(param,null);
      if (input_type != null)
        setType(input_type);
      return true;
    case Constants.Name.AUTOFOCUS:
      Boolean result = WXUtils.getBoolean(param, null);
      if (result != null)
        setAutofocus(result);
      return true;
    case Constants.Name.COLOR:
      String color = WXUtils.getString(param,null);
      if (color != null)
        setColor(color);
      return true;
    case Constants.Name.FONT_SIZE:
      String fontsize = WXUtils.getString(param,null);
      if (fontsize != null)
        setFontSize(fontsize);
      return true;
    case Constants.Name.TEXT_ALIGN:
      String text_align = WXUtils.getString(param,null);
      if (text_align != null)
        setTextAlign(text_align);
      return true;
    case Constants.Name.SINGLELINE:
      Boolean singLineResult = WXUtils.getBoolean(param, null);
      if (singLineResult != null)
        setSingleLine(singLineResult);
      return true;
    case Constants.Name.LINES:
      Integer lines = WXUtils.getInteger(param, null);
      if (lines != null)
        setLines(lines);
      return true;
    case Constants.Name.MAX_LENGTH:
      Integer maxlength = WXUtils.getInteger(param, null);
      if (maxlength != null)
        setMaxLength(maxlength);
      return true;
    case Constants.Name.MAXLENGTH:
      Integer maxLength = WXUtils.getInteger(param, null);
      if (maxLength != null)
        setMaxLength(maxLength);
        return true;
    case Constants.Name.MAX:
      setMax(String.valueOf(param));
      return true;
    case Constants.Name.MIN:
      setMin(String.valueOf(param));
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 20
Source File: WXSlider.java    From weex-uikit with MIT License 4 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
  switch (key) {
    case Constants.Name.VALUE:
      String value = WXUtils.getString(param, null);
      if (value != null) {
        setValue(value);
      }
      return true;
    case Constants.Name.AUTO_PLAY:
      String aotu_play = WXUtils.getString(param, null);
      if (aotu_play != null) {
        setAutoPlay(aotu_play);
      }
      return true;
    case Constants.Name.SHOW_INDICATORS:
      String indicators = WXUtils.getString(param, null);
      if (indicators != null) {
        setShowIndicators(indicators);
      }
      return true;
    case Constants.Name.INTERVAL:
      Integer interval = WXUtils.getInteger(param, null);
      if (interval != null) {
        setInterval(interval);
      }
      return true;
    case Constants.Name.INDEX:
      Integer index = WXUtils.getInteger(param, null);
      if (index != null) {
        setIndex(index);
      }
      return true;
    case Constants.Name.OFFSET_X_ACCURACY:
      Float accuracy = WXUtils.getFloat(param, 0.1f);
      if (accuracy != 0) {
        setOffsetXAccuracy(accuracy);
      }
      return true;
    case Constants.Name.SCROLLABLE:
      boolean scrollable = WXUtils.getBoolean(param, true);
      setScrollable(scrollable);
      return true;
  }
  return super.setProperty(key, param);
}