com.taobao.weex.common.Constants Java Examples

The following examples show how to use com.taobao.weex.common.Constants. 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: WXVideo.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@WXComponentProp(name = Constants.Name.PLAY_STATUS)
public void setPlaystatus(String playstatus) {

  if (mPrepared && !mError && !mStopped) {
    if (playstatus.equals(Constants.Value.PLAY)) {
      mWrapper.start();
    } else if (playstatus.equals(Constants.Value.PAUSE)) {
      mWrapper.pause();
    } else if (playstatus.equals(Constants.Value.STOP)) {
      mWrapper.stopPlayback();
      mStopped = true;
    }
  } else if ((mError || mStopped) && playstatus.equals(Constants.Value.PLAY)) {
    mError = false;
    mWrapper.resume();

    mWrapper.getProgressBar().setVisibility(View.VISIBLE);
  }
}
 
Example #3
Source File: WXScroller.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
protected MeasureOutput measure(int width, int height) {
  MeasureOutput measureOutput = new MeasureOutput();
  if (this.mOrientation == Constants.Orientation.HORIZONTAL) {
    int screenW = WXViewUtils.getScreenWidth(WXEnvironment.sApplication);
    int weexW = WXViewUtils.getWeexWidth(getInstanceId());
    measureOutput.width = width > (weexW >= screenW ? screenW : weexW) ? FrameLayout.LayoutParams.MATCH_PARENT
                                                                       : width;
    measureOutput.height = height;
  } else {
    int screenH = WXViewUtils.getScreenHeight(WXEnvironment.sApplication);
    int weexH = WXViewUtils.getWeexHeight(getInstanceId());
    measureOutput.height = height > (weexH >= screenH ? screenH : weexH) ? FrameLayout.LayoutParams.MATCH_PARENT
                                                                         : height;
    measureOutput.width = width;
  }
  return measureOutput;
}
 
Example #4
Source File: WXScroller.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public void scrollBy(final int x, final int y, final boolean smooth) {
  if (getInnerView() == null) {
    return;
  }

  getInnerView().postDelayed(new Runnable() {
    @Override
    public void run() {
      if (mOrientation == Constants.Orientation.VERTICAL) {
        if (smooth) {
          ((WXScrollView) getInnerView()).smoothScrollBy(0, y);
        } else {
          ((WXScrollView) getInnerView()).scrollBy(0, y);
        }
      } else {
        if (smooth) {
          ((WXHorizontalScrollView) getInnerView()).smoothScrollBy(x, 0);
        } else {
          ((WXHorizontalScrollView) getInnerView()).scrollBy(x, 0);
        }
      }
      getInnerView().invalidate();
    }
  }, 16);
}
 
Example #5
Source File: WXScroller.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
private boolean shouldReport(int x, int y) {
  if (mLastReport.x == -1 && mLastReport.y == -1) {
    mLastReport.x = x;
    mLastReport.y = y;
    return true;
  }

  if (mOrientation == Constants.Orientation.HORIZONTAL
          && Math.abs(x - mLastReport.x) >= mOffsetAccuracy) {
    mLastReport.x = x;
    mLastReport.y = y;
    return true;
  }

  if (mOrientation == Constants.Orientation.VERTICAL
          && Math.abs(y - mLastReport.y) >= mOffsetAccuracy) {
    mLastReport.x = x;
    mLastReport.y = y;
    return true;
  }

  return false;
}
 
Example #6
Source File: Textarea.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
protected void appleStyleAfterCreated(WXEditText editText) {
  super.appleStyleAfterCreated(editText);
  String rowsStr = (String) getDomObject().getStyles().get(Constants.Name.ROWS);

  int rows = TextAreaEditTextDomObject.DEFAULT_ROWS;
  try{
    if(!TextUtils.isEmpty(rowsStr)) {
      rows = Integer.parseInt(rowsStr);
    }
  }catch (NumberFormatException e){
    //ignore
    e.printStackTrace();
  }

  editText.setLines(rows);
  editText.setMinLines(rows);
}
 
Example #7
Source File: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
private void fireScrollEvent(RecyclerView recyclerView, int offsetX, int offsetY) {
  int contentWidth = recyclerView.getMeasuredWidth() + recyclerView.computeHorizontalScrollRange();
  int contentHeight = recyclerView.computeVerticalScrollRange();

  Map<String, Object> event = new HashMap<>(2);
  Map<String, Object> contentSize = new HashMap<>(2);
  Map<String, Object> contentOffset = new HashMap<>(2);

  contentSize.put(Constants.Name.WIDTH, WXViewUtils.getWebPxByWidth(contentWidth, getInstance().getInstanceViewPortWidth()));
  contentSize.put(Constants.Name.HEIGHT, WXViewUtils.getWebPxByWidth(contentHeight, getInstance().getInstanceViewPortWidth()));

  contentOffset.put(Constants.Name.X, - WXViewUtils.getWebPxByWidth(offsetX, getInstance().getInstanceViewPortWidth()));
  contentOffset.put(Constants.Name.Y, - WXViewUtils.getWebPxByWidth(offsetY, getInstance().getInstanceViewPortWidth()));
  event.put(Constants.Name.CONTENT_SIZE, contentSize);
  event.put(Constants.Name.CONTENT_OFFSET, contentOffset);

  fireEvent(Constants.Event.SCROLL, event);
}
 
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: WXStyle.java    From weex-uikit with MIT License 6 votes vote down vote up
public static int getFontWeight(Map<String, Object> style) {
  int typeface = android.graphics.Typeface.NORMAL;
  if (style != null) {
    Object temp = style.get(Constants.Name.FONT_WEIGHT);
    if (temp != null) {
      String fontWeight = temp.toString();
      switch (fontWeight){
        case "600":
        case "700":
        case "800":
        case "900":
        case Constants.Value.BOLD:
          typeface=Typeface.BOLD;
          break;
      }
    }
  }
  return typeface;
}
 
Example #10
Source File: WXAttr.java    From weex-uikit with MIT License 6 votes vote down vote up
public WXImageQuality getImageQuality() {

    Object obj = get(Constants.Name.QUALITY);
    if (obj == null) {
      obj = get(Constants.Name.IMAGE_QUALITY);
    }
    if (obj == null) {
      return WXImageQuality.LOW;
    }
    WXImageQuality waImageQuality = WXImageQuality.LOW;
    String imageQuality = obj.toString();
    if (imageQuality.equals(Constants.Value.ORIGINAL)) {
      waImageQuality = WXImageQuality.ORIGINAL;
    } else if (imageQuality.equals(Constants.Value.LOW)) {
      waImageQuality = WXImageQuality.LOW;
    } else if (imageQuality.equals(Constants.Value.NORMAL)) {
      waImageQuality = WXImageQuality.NORMAL;
    } else if (imageQuality.equals(Constants.Value.HIGH)) {
      waImageQuality = WXImageQuality.HIGH;
    }

    return waImageQuality;
  }
 
Example #11
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 #12
Source File: WXText.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.LINES:
    case Constants.Name.FONT_SIZE:
    case Constants.Name.FONT_WEIGHT:
    case Constants.Name.FONT_STYLE:
    case Constants.Name.COLOR:
    case Constants.Name.TEXT_DECORATION:
    case Constants.Name.FONT_FAMILY:
    case Constants.Name.TEXT_ALIGN:
    case Constants.Name.TEXT_OVERFLOW:
    case Constants.Name.LINE_HEIGHT:
    case Constants.Name.VALUE:
      return true;
    default:
      return super.setProperty(key, param);
  }
}
 
Example #13
Source File: WXStyle.java    From weex-uikit with MIT License 5 votes vote down vote up
public float getOpacity() {
  Object object = get(Constants.Name.OPACITY);
  float opacity = 1;
  if (object == null) {
    return opacity;
  }
  return WXUtils.getFloat(object);
}
 
Example #14
Source File: WXStyle.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public float getPaddingTop(int viewport) {
  float temp = WXUtils.getFloatByViewport(get(Constants.Name.PADDING_TOP), viewport);
  if (WXUtils.isUndefined(temp)) {
    temp = WXUtils.getFloatByViewport(get(Constants.Name.PADDING), viewport);
  }
  return temp;
}
 
Example #15
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public boolean onBackPressed() {
  WXComponent comp = getRootComponent();
  if(comp != null) {
    WXEvent events= comp.getDomObject().getEvents();
    boolean hasBackPressed = events.contains(Constants.Event.CLICKBACKITEM);
    if (hasBackPressed) {
      fireEvent(comp.getRef(), Constants.Event.CLICKBACKITEM,null, null);
    }
    return hasBackPressed;
  }
  return false;
}
 
Example #16
Source File: WXStyle.java    From weex-uikit with MIT License 5 votes vote down vote up
public static WXTextDecoration getTextDecoration(Map<String, Object> style) {
  Object obj = style.get(Constants.Name.TEXT_DECORATION);
  if (obj == null) {
    return WXTextDecoration.NONE;
  }
  String textDecoration = obj.toString();
  if (textDecoration.equals("underline")) {
    return WXTextDecoration.UNDERLINE;
  }
  if (textDecoration.equals("line-through")) {
    return WXTextDecoration.LINETHROUGH;
  }
  return WXTextDecoration.NONE;
}
 
Example #17
Source File: Textarea.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.ROWS:
      Integer rows = WXUtils.getInteger(param,null);
      if (rows != null)
        setRows(rows);
      return true;
  }
  return super.setProperty(key, param);
}
 
Example #18
Source File: WXStyle.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public float getPaddingLeft() {
  float temp = WXUtils.getFloat(get(Constants.Name.PADDING_LEFT));
  if (WXUtils.isUndefined(temp)) {
    temp = WXUtils.getFloat(get(Constants.Name.PADDING));
  }
  return temp;
}
 
Example #19
Source File: WXAttr.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public String getImageSrc() {
  Object src = get(Constants.Name.SRC);
  if (src == null) {
    return null;
  }
  return src.toString();
}
 
Example #20
Source File: WXAttr.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public String getLoadMoreOffset() {
  Object src = get(Constants.Name.LOADMOREOFFSET);
  if (src == null) {
    return null;
  }
  return src.toString();
}
 
Example #21
Source File: WXComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public void setVisibility(String visibility) {
  View view;
  if ((view = getRealView()) != null) {
    if (TextUtils.equals(visibility, Constants.Value.VISIBLE)) {
      view.setVisibility(View.VISIBLE);
    } else if (TextUtils.equals(visibility, Constants.Value.HIDDEN)) {
      view.setVisibility(View.GONE);
    }
  }
}
 
Example #22
Source File: WXStyle.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public float getMarginLeft() {
  float temp = WXUtils.getFloat(get(Constants.Name.MARGIN_LEFT));
  if (WXUtils.isUndefined(temp)) {
    temp = WXUtils.getFloat(get(Constants.Name.MARGIN));
  }
  return temp;
}
 
Example #23
Source File: WXTextDomObject.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public void updateAttr(Map<String, Object> attrs) {
  swap();
  super.updateAttr(attrs);
  if (attrs.containsKey(Constants.Name.VALUE)) {
    mText = WXAttr.getValue(attrs);
  }
}
 
Example #24
Source File: WXLoadingIndicator.java    From weex-uikit with MIT License 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 #25
Source File: Textarea.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.ROWS:
      Integer rows = WXUtils.getInteger(param,null);
      if (rows != null)
        setRows(rows);
      return true;
  }
  return super.setProperty(key, param);
}
 
Example #26
Source File: WXStyle.java    From weex-uikit with MIT License 5 votes vote down vote up
public CSSAlign getAlignItems() {
  Object alignItems = get(Constants.Name.ALIGN_ITEMS);
  if (alignItems == null) {
    return CSSAlign.STRETCH;
  }
  return CSSAlignConvert.convert2AlignItems(alignItems.toString().trim());
}
 
Example #27
Source File: WXLoading.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoading() {
  ImmutableDomObject domObject = getDomObject();
  if (domObject != null && domObject.getEvents().contains(Constants.Event.ONLOADING)) {
    fireEvent(Constants.Event.ONLOADING);
  }
}
 
Example #28
Source File: WXScroller.java    From weex-uikit with MIT License 5 votes vote down vote up
@WXComponentProp(name = Constants.Name.SCROLLABLE)
public void setScrollable(boolean scrollable) {
  View hostView = getInnerView();
  if(hostView instanceof WXHorizontalScrollView) {
    ((WXHorizontalScrollView)hostView).setScrollable(scrollable);
  }else if(hostView instanceof WXScrollView) {
    ((WXScrollView)hostView).setScrollable(scrollable);
  }
}
 
Example #29
Source File: WXLoading.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 #30
Source File: AbstractEditComponent.java    From weex-uikit with MIT License 5 votes vote down vote up
@WXComponentProp(name = Constants.Name.LINES)
public void setLines(int lines) {
  if (getHostView() == null) {
    return;
  }
  getHostView().setLines(lines);
}