com.taobao.weex.ui.component.WXText Java Examples

The following examples show how to use com.taobao.weex.ui.component.WXText. 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: WXSDKEngine.java    From weex with Apache License 2.0 6 votes vote down vote up
private static void register() {
  try {
    registerComponent(WXBasicComponentType.TEXT, WXText.class, false);
    registerComponent(WXBasicComponentType.IMG, WXImage.class, false);
    registerComponent(WXBasicComponentType.DIV, WXDiv.class, false);
    registerComponent(WXBasicComponentType.IMAGE, WXImage.class, false);
    registerComponent(WXBasicComponentType.CONTAINER, WXDiv.class, false);
    registerComponent(WXBasicComponentType.SCROLLER, WXScroller.class, false);
    registerComponent(WXBasicComponentType.SLIDER, WXSlider.class, true);

    registerComponent(WXListComponent.class, false,WXBasicComponentType.LIST,WXBasicComponentType.VLIST);
    registerComponent(HorizontalListComponent.class,false,WXBasicComponentType.HLIST);
    registerComponent(WXBasicComponentType.CELL, WXCell.class, true);
    registerComponent(WXBasicComponentType.INDICATOR, WXIndicator.class, true);
    registerComponent(WXBasicComponentType.VIDEO, WXVideo.class, false);
    registerComponent(WXBasicComponentType.INPUT, WXInput.class, false);
    registerComponent(WXBasicComponentType.SWITCH, WXSwitch.class, false);
    registerComponent(WXBasicComponentType.A, WXA.class, false);
    registerComponent(WXBasicComponentType.EMBED, WXEmbed.class, true);
    registerComponent(WXBasicComponentType.WEB, WXWeb.class);
    registerComponent(WXBasicComponentType.REFRESH, WXRefresh.class);
    registerComponent(WXBasicComponentType.LOADING, WXLoading.class);
    registerComponent(WXBasicComponentType.LOADING_INDICATOR, WXLoadingIndicator.class);

    registerModule("dom", WXDomModule.class, true);
    registerModule("modal", WXModalUIModule.class, false);
    registerModule("instanceWrap", WXInstanceWrap.class, true);
    registerModule("animation", WXAnimationModule.class, true);
    registerModule("webview", WXWebViewModule.class, true);
    registerModule("navigator", WXNavigatorModule.class);
    registerModule("stream", WXStreamModule.class);

    registerDomObject(WXBasicComponentType.TEXT, WXTextDomObject.class);
    registerDomObject(WXBasicComponentType.INPUT, WXTextDomObject.class);
    registerDomObject(WXBasicComponentType.SWITCH, WXSwitchDomObject.class);
  } catch (WXException e) {
    WXLogUtils.e("[WXSDKEngine] register:" + WXLogUtils.getStackTrace(e));
  }
}
 
Example #2
Source File: WXTextDomObject.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * Update {@link #spannableStringBuilder} according to the give charSequence and {@link #style}
 * @param text the give raw text.
 * @return an editable contains text and spans
 */
private Editable updateSpannableStringBuilder(String text) {
  spannableStringBuilder.clear();
  if (text != null) {
    spannableStringBuilder.append(text);
  }
  List<SetSpanOperation> ops = createSetSpanOperation(spannableStringBuilder.length());
  if (mFontSize == UNSET) {
    spannableStringBuilder.setSpan(
        new AbsoluteSizeSpan(WXText.sDEFAULT_SIZE), 0, spannableStringBuilder
            .length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
  }
  Collections.reverse(ops);
  for (SetSpanOperation op : ops) {
    op.execute(spannableStringBuilder);
  }
  return spannableStringBuilder;
}
 
Example #3
Source File: BasicEditTextDomObject.java    From weex-uikit with MIT License 5 votes vote down vote up
public BasicEditTextDomObject() {
  super();
  mPaint.setTextSize(WXViewUtils.getRealPxByWidth(WXText.sDEFAULT_SIZE,getViewPortWidth()));
  setMeasureFunction(new MeasureFunction() {
    @Override
    public void measure(CSSNode node, float width, MeasureOutput measureOutput) {
      if (CSSConstants.isUndefined(width)) {
        width = node.cssstyle.maxWidth;
      }
      measureOutput.height = getMeasureHeight();
      measureOutput.width = width;
    }
  });
}
 
Example #4
Source File: WXStyle.java    From weex with Apache License 2.0 5 votes vote down vote up
public int getTimeFontSize() {
  int fontSize = WXUtils.getInt(get("timeFontSize"));
  if (fontSize <= 0) {
    fontSize = WXText.sDEFAULT_SIZE;
  }
  return fontSize;
}
 
Example #5
Source File: WXStyle.java    From weex with Apache License 2.0 5 votes vote down vote up
public static int getFontSize(Map<String, Object> style) {
  if (style == null) {
    return (int) WXViewUtils.getRealPxByWidth(WXText.sDEFAULT_SIZE);
  }
  int fontSize = WXUtils.getInt(style.get(WXDomPropConstant.WX_FONTSIZE));
  if (fontSize <= 0) {
    fontSize = WXText.sDEFAULT_SIZE;
  }
  return (int) WXViewUtils.getRealPxByWidth(fontSize);
}
 
Example #6
Source File: WXTextView.java    From weex-uikit with MIT License 5 votes vote down vote up
public void setTextLayout(Layout layout) {
  this.textLayout = layout;
  if(layout!=null){
    setContentDescription(layout.getText());
  }
  if (mWeakReference != null) {
    WXText wxText = mWeakReference.get();
    if (wxText != null) {
      wxText.readyToRender();
    }
  }
}
 
Example #7
Source File: WXTextDomObject.java    From weex-uikit with MIT License 5 votes vote down vote up
protected void updateSpannable(Spannable spannable, int spanFlag) {
  List<SetSpanOperation> ops = createSetSpanOperation(spannable.length(), spanFlag);
  if (mFontSize == UNSET) {
    ops.add(new SetSpanOperation(0, spannable.length(),
                                 new AbsoluteSizeSpan(WXText.sDEFAULT_SIZE), spanFlag));
  }
  Collections.reverse(ops);
  for (SetSpanOperation op : ops) {
    op.execute(spannable);
  }
}
 
Example #8
Source File: WXStyle.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public static int getFontSize(Map<String, Object> style,int viewPortW) {
  if (style == null) {
    return (int) WXViewUtils.getRealPxByWidth(WXText.sDEFAULT_SIZE,viewPortW);
  }
  int fontSize = WXUtils.getInt(style.get(Constants.Name.FONT_SIZE));
  if (fontSize <= 0) {
    fontSize = WXText.sDEFAULT_SIZE;
  }
  return (int) WXViewUtils.getRealPxByWidth(fontSize,viewPortW);
}
 
Example #9
Source File: WXStyle.java    From weex-uikit with MIT License 5 votes vote down vote up
public int getTimeFontSize() {
  int fontSize = WXUtils.getInt(get("timeFontSize"));
  if (fontSize <= 0) {
    fontSize = WXText.sDEFAULT_SIZE;
  }
  return fontSize;
}
 
Example #10
Source File: WXStyle.java    From weex-uikit with MIT License 5 votes vote down vote up
public static int getFontSize(Map<String, Object> style,int viewPortW) {
  if (style == null) {
    return (int) WXViewUtils.getRealPxByWidth(WXText.sDEFAULT_SIZE,viewPortW);
  }
  int fontSize = WXUtils.getInt(style.get(Constants.Name.FONT_SIZE));
  if (fontSize <= 0) {
    fontSize = WXText.sDEFAULT_SIZE;
  }
  return (int) WXViewUtils.getRealPxByWidth(fontSize,viewPortW);
}
 
Example #11
Source File: WXTextView.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public void setTextLayout(Layout layout) {
  this.textLayout = layout;
  if(layout!=null && !mIsLabelSet){
    setContentDescription(layout.getText());
  }
  if (mWeakReference != null) {
    WXText wxText = mWeakReference.get();
    if (wxText != null) {
      wxText.readyToRender();
    }
  }
}
 
Example #12
Source File: WXTextDomObject.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
protected void updateSpannable(Spannable spannable, int spanFlag) {
  List<SetSpanOperation> ops = createSetSpanOperation(spannable.length(), spanFlag);
  if (mFontSize == UNSET) {
    ops.add(new SetSpanOperation(0, spannable.length(),
                                 new AbsoluteSizeSpan(WXText.sDEFAULT_SIZE), spanFlag));
  }
  Collections.reverse(ops);
  for (SetSpanOperation op : ops) {
    op.execute(spannable);
  }
}
 
Example #13
Source File: BasicEditTextDomObject.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public BasicEditTextDomObject() {
  super();
  mPaint.setTextSize(WXViewUtils.getRealPxByWidth(WXText.sDEFAULT_SIZE,getViewPortWidth()));
  setMeasureFunction(new MeasureFunction() {
    @Override
    public void measure(CSSNode node, float width, MeasureOutput measureOutput) {
      if (CSSConstants.isUndefined(width)) {
        width = node.cssstyle.maxWidth;
      }
      measureOutput.height = getMeasureHeight();
      measureOutput.width = width;
    }
  });
}
 
Example #14
Source File: WXStyle.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public int getTimeFontSize() {
  int fontSize = WXUtils.getInt(get("timeFontSize"));
  if (fontSize <= 0) {
    fontSize = WXText.sDEFAULT_SIZE;
  }
  return fontSize;
}
 
Example #15
Source File: WXTextView.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public WXText getComponent() {
   return null != mWeakReference ? mWeakReference.get() : null;
}
 
Example #16
Source File: WXTextView.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
@Override
public void holdComponent(WXText component) {
  mWeakReference = new WeakReference<>(component);
}
 
Example #17
Source File: WXTextView.java    From weex-uikit with MIT License 4 votes vote down vote up
@Override
public void holdComponent(WXText component) {
  mWeakReference = new WeakReference<>(component);
}
 
Example #18
Source File: WXSDKEngine.java    From weex-uikit with MIT License 3 votes vote down vote up
private static void register() {
  BatchOperationHelper batchHelper = new BatchOperationHelper(WXBridgeManager.getInstance());
  try {
    registerComponent(
      new SimpleComponentHolder(
        WXText.class,
        new WXText.Creator()
      ),
      false,
      WXBasicComponentType.TEXT
    );
    registerComponent(
      new SimpleComponentHolder(
        WXDiv.class,
        new WXDiv.Ceator()
      ),
      false,
      WXBasicComponentType.CONTAINER,
      WXBasicComponentType.DIV,
      WXBasicComponentType.HEADER,
      WXBasicComponentType.FOOTER
    );
    registerComponent(
      new SimpleComponentHolder(
        WXImage.class,
        new WXImage.Ceator()
      ),
      false,
      WXBasicComponentType.IMAGE,
      WXBasicComponentType.IMG
    );
    registerComponent(
      new SimpleComponentHolder(
        WXScroller.class,
        new WXScroller.Creator()
      ),
      false,
      WXBasicComponentType.SCROLLER
    );
    registerComponent(
      new SimpleComponentHolder(
        WXSlider.class,
        new WXSlider.Creator()
      ),
      true,
      WXBasicComponentType.SLIDER
    );
    registerComponent(
      new SimpleComponentHolder(
              WXSliderNeighbor.class,
        new WXSliderNeighbor.Creator()
      ),
      true,
      WXBasicComponentType.SLIDER_NEIGHBOR
    );
    registerComponent(SimpleListComponent.class,false,"simplelist");
    registerComponent(WXListComponent.class, false,WXBasicComponentType.LIST,WXBasicComponentType.VLIST);
    registerComponent(HorizontalListComponent.class,false,WXBasicComponentType.HLIST);
    registerComponent(WXBasicComponentType.CELL, WXCell.class, true);
    registerComponent(WXBasicComponentType.INDICATOR, WXIndicator.class, true);
    registerComponent(WXBasicComponentType.VIDEO, WXVideo.class, false);
    registerComponent(WXBasicComponentType.INPUT, WXInput.class, false);
    registerComponent(WXBasicComponentType.TEXTAREA, Textarea.class,false);
    registerComponent(WXBasicComponentType.SWITCH, WXSwitch.class, false);
    registerComponent(WXBasicComponentType.A, WXA.class, false);
    registerComponent(WXBasicComponentType.EMBED, WXEmbed.class, true);
    registerComponent(WXBasicComponentType.WEB, WXWeb.class);
    registerComponent(WXBasicComponentType.REFRESH, WXRefresh.class);
    registerComponent(WXBasicComponentType.LOADING, WXLoading.class);
    registerComponent(WXBasicComponentType.LOADING_INDICATOR, WXLoadingIndicator.class);
    registerComponent(WXBasicComponentType.HEADER, WXHeader.class);

    registerModule("modal", WXModalUIModule.class, false);
    registerModule("instanceWrap", WXInstanceWrap.class, true);
    registerModule("animation", WXAnimationModule.class, true);
    registerModule("webview", WXWebViewModule.class, true);
    registerModule("navigator", WXNavigatorModule.class);
    registerModule("stream", WXStreamModule.class);
    registerModule("timer", WXTimerModule.class, true);
    registerModule("storage", WXStorageModule.class, true);
    registerModule("clipboard", WXClipboardModule.class, true);
    registerModule("globalEvent",WXGlobalEventModule.class);
    registerModule("picker", WXPickersModule.class);
    registerModule("meta", WXMetaModule.class,true);
    registerModule("webSocket", WebSocketModule.class);


    registerDomObject(WXBasicComponentType.INDICATOR, WXIndicator.IndicatorDomNode.class);
    registerDomObject(WXBasicComponentType.TEXT, WXTextDomObject.class);
    registerDomObject(WXBasicComponentType.INPUT, BasicEditTextDomObject.class);
    registerDomObject(WXBasicComponentType.TEXTAREA, TextAreaEditTextDomObject.class);
    registerDomObject(WXBasicComponentType.SWITCH, WXSwitchDomObject.class);
    registerDomObject(WXBasicComponentType.LIST, WXListDomObject.class);
    registerDomObject(WXBasicComponentType.VLIST, WXListDomObject.class);
    registerDomObject(WXBasicComponentType.HLIST, WXListDomObject.class);
    registerDomObject(WXBasicComponentType.SCROLLER, WXScrollerDomObject.class);
  } catch (WXException e) {
    WXLogUtils.e("[WXSDKEngine] register:", e);
  }
  batchHelper.flush();
}