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

The following examples show how to use com.taobao.weex.utils.WXUtils#getBoolean() . 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: 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 2
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 3
Source File: WXScroller.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_SCROLLBAR:
      Boolean result = WXUtils.getBoolean(param,null);
      if (result != null)
        setShowScrollbar(result);
      return true;
    case Constants.Name.SCROLLABLE:
      boolean scrollable = WXUtils.getBoolean(param, true);
      setScrollable(scrollable);
      return true;
    case Constants.Name.OFFSET_ACCURACY:
      int accuracy = WXUtils.getInteger(param, 10);
      setOffsetAccuracy(accuracy);
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 4
Source File: WXScroller.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void scrollTo(WXComponent component, Map<String, Object> options) {
  float offsetFloat = 0;
  boolean smooth = true;

  if (options != null) {
    String offset = options.get(Constants.Name.OFFSET) == null ? "0" : options.get(Constants.Name.OFFSET).toString();
    smooth = WXUtils.getBoolean(options.get(Constants.Name.ANIMATED), true);
    if (offset != null) {
      try {
        offsetFloat = WXViewUtils.getRealPxByWidth(Float.parseFloat(offset), getInstance().getInstanceViewPortWidth());
      }catch (Exception e ){
        WXLogUtils.e("Float parseFloat error :"+e.getMessage());
      }
    }
  }

  int viewYInScroller=component.getAbsoluteY() - getAbsoluteY();
  int viewXInScroller=component.getAbsoluteX() - getAbsoluteX();

  scrollBy(viewXInScroller - getScrollX() + (int) offsetFloat, viewYInScroller - getScrollY() + (int) offsetFloat, smooth);
}
 
Example 5
Source File: WXSlider.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
protected FrameLayout initComponentHostView(@NonNull Context context) {
  FrameLayout view = new FrameLayout(context);
  // init view pager
  if (getDomObject() != null && getDomObject().getAttrs() != null) {
    Object obj = getDomObject().getAttrs().get(INFINITE);
    isInfinite = WXUtils.getBoolean(obj, true);
  }
  FrameLayout.LayoutParams pagerParams = new FrameLayout.LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  mViewPager = new WXCircleViewPager(context);
  mViewPager.setCircle(isInfinite);
  mViewPager.setLayoutParams(pagerParams);

  // init adapter
  mAdapter = new WXCirclePageAdapter(isInfinite);
  mViewPager.setAdapter(mAdapter);
  // add to parent
  view.addView(mViewPager);
  mViewPager.addOnPageChangeListener(mPageChangeListener);

  registerActivityStateListener();

  return view;
}
 
Example 6
Source File: WXWebComponent.java    From CrazyDaily 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;
        case Constants.Name.SOURCE:
            String source = WXUtils.getString(param, null);
            if (source != null) {
                setSource(source);
            }
            return true;
        default:
            return super.setProperty(key, param);
    }
}
 
Example 7
Source File: BasicListComponent.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 LOADMOREOFFSET:
      return true;
    case Constants.Name.SCROLLABLE:
      boolean scrollable = WXUtils.getBoolean(param, true);
      setScrollable(scrollable);
      return true;
    case Constants.Name.OFFSET_ACCURACY:
      int accuracy = WXUtils.getInteger(param, 10);
      setOffsetAccuracy(accuracy);
      return true;
    case Constants.Name.DRAGGABLE:
      boolean draggable = WXUtils.getBoolean(param,false);
      setDraggable(draggable);
      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: 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 10
Source File: WXModule.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@JSMethod
public void addEventListener(String eventName, String callback, Map<String, Object> options) {
  if (TextUtils.isEmpty(eventName) || TextUtils.isEmpty(callback)) {
    return;
  }
  boolean isOnce = false;
  if (options != null && options.size() > 0 && options.containsKey("once")) {
    Object temp = options.get("once");
    if (WXUtils.getBoolean(temp,false)) {
      isOnce = true;
    }
  }
  mKeepAlives.put(callback, isOnce);
  if(mEvents.get(eventName)==null){
    mEvents.put(eventName,new ArrayList<String>());
  }
  mEvents.get(eventName).add(callback);
}
 
Example 11
Source File: BasicListComponent.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
protected boolean setProperty(String key, Object param) {
  switch (key) {
    case LOADMOREOFFSET:
      return true;
    case Constants.Name.SCROLLABLE:
      boolean scrollable = WXUtils.getBoolean(param, true);
      setScrollable(scrollable);
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 12
Source File: WXSwitch.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.CHECKED:
      Boolean result = WXUtils.getBoolean(param, null);
      if (result != null) {
        setChecked(result);
      }
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 13
Source File: WXScroller.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.SHOW_SCROLLBAR:
      Boolean result = WXUtils.getBoolean(param,null);
      if (result != null)
        setShowScrollbar(result);
      return true;
    case Constants.Name.SCROLLABLE:
      boolean scrollable = WXUtils.getBoolean(param, true);
      setScrollable(scrollable);
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 14
Source File: WXSwitch.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.CHECKED:
      Boolean result = WXUtils.getBoolean(param, null);
      if (result != null) {
        setChecked(result);
      }
      return true;
  }
  return super.setProperty(key, param);
}
 
Example 15
Source File: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
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 16
Source File: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
/**
 * 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 17
Source File: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
@Override
public void scrollTo(WXComponent component, Map<String, Object> options) {
  float offsetFloat = 0;
  boolean smooth = true;

  if (options != null) {
    String offsetStr = options.get(Constants.Name.OFFSET) == null ? "0" : options.get(Constants.Name.OFFSET).toString();
    smooth = WXUtils.getBoolean(options.get(Constants.Name.ANIMATED), true);
    if (offsetStr != null) {
      try {
        offsetFloat = WXViewUtils.getRealPxByWidth(Float.parseFloat(offsetStr), getInstance().getInstanceViewPortWidth());
      }catch (Exception e ){
        WXLogUtils.e("Float parseFloat error :"+e.getMessage());
      }
    }
  }

  final int offset = (int) offsetFloat;

  T bounceRecyclerView = getHostView();
  if (bounceRecyclerView == null) {
    return;
  }

  WXComponent parent = component;
  WXCell cell = null;
  while (parent != null) {
    if (parent instanceof WXCell) {
      cell = (WXCell) parent;
      break;
    }
    parent = parent.getParent();
  }

  if (cell != null) {
    final int pos = mChildren.indexOf(cell);
    final WXRecyclerView view = bounceRecyclerView.getInnerView();

    if (!smooth) {
      RecyclerView.LayoutManager layoutManager = view.getLayoutManager();
      if (layoutManager instanceof LinearLayoutManager) {
        //GridLayoutManager is also instance of LinearLayoutManager
        ((LinearLayoutManager) layoutManager).scrollToPositionWithOffset(pos, -offset);
      } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        ((StaggeredGridLayoutManager) layoutManager).scrollToPositionWithOffset(pos, -offset);
      }
      //Any else?
    } else {
      view.smoothScrollToPosition(pos);
      if (offset != 0) {
        view.addOnScrollListener(new RecyclerView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
              if (getOrientation() == Constants.Orientation.VERTICAL) {
                recyclerView.smoothScrollBy(0, offset);
              } else {
                recyclerView.smoothScrollBy(offset, 0);
              }
              recyclerView.removeOnScrollListener(this);
            }
          }
        });
      }
    }
  }
}
 
Example 18
Source File: AbstractEditComponent.java    From ucar-weex-core with Apache License 2.0 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;
    case Constants.Name.RETURN_KEY_TYPE:
      setReturnKeyType(String.valueOf(param));
      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 ucar-weex-core with Apache License 2.0 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);
}