Search in sources :

Example 1 with BMRichUtil

use of com.eros.framework.utils.BMRichUtil in project WeexErosFramework by bmfe.

the class BMRich method aggregateChild.

private void aggregateChild(WXComponent child) {
    if (child != null) {
        ImmutableDomObject domObject = child.getDomObject();
        if (domObject instanceof WXTextDomObject) {
            WXTextDomObject textDomObject = (WXTextDomObject) domObject;
            // Layout extra = textDomObject.getExtra();
            // Log.e("extra", "extra>>>>>>" + extra + "count>>>>" + mSubCount);
            BMRichUtil util = new BMRichUtil();
            Spanned test = util.createSpan(textDomObject.getAttrs(), textDomObject.getStyles());
            // if (extra instanceof StaticLayout) {
            // CharSequence text = ((StaticLayout) extra).getText();
            SpannableString spannableString = ((SpannableString) test);
            Object[] spans = spannableString.getSpans(0, spannableString.length(), Object.class);
            for (Object span : spans) {
                mSpans.add(new RichTextDomObject.BMRichSpan(span, mText.length(), spannableString.length() + mText.length()));
            }
            // 设置span的事件
            WXEvent events = domObject.getEvents();
            for (String event : events) {
                appendChildEvent(event, spannableString, textDomObject);
            }
            mText.append(spannableString.toString());
            spannableStringBuilder.append(spannableString);
        // }
        }
    }
    mSubCount--;
    // if (mSubCount == 0) {
    // 子控件添加完毕 更新
    update();
// }
}
Also used : SpannableString(android.text.SpannableString) RichTextDomObject(com.taobao.weex.dom.RichTextDomObject) WXEvent(com.taobao.weex.dom.WXEvent) ImmutableDomObject(com.taobao.weex.dom.ImmutableDomObject) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject) WXDomObject(com.taobao.weex.dom.WXDomObject) ImmutableDomObject(com.taobao.weex.dom.ImmutableDomObject) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject) RichTextDomObject(com.taobao.weex.dom.RichTextDomObject) JSONObject(com.alibaba.fastjson.JSONObject) SpannableString(android.text.SpannableString) BMRichUtil(com.eros.framework.utils.BMRichUtil) Spanned(android.text.Spanned)

Example 2 with BMRichUtil

use of com.eros.framework.utils.BMRichUtil in project WeexErosFramework by bmfe.

the class BMRich method organizeChild.

private void organizeChild(WXDomObject object) {
    if (object instanceof WXTextDomObject) {
        WXTextDomObject textDomObject = (WXTextDomObject) object;
        BMRichUtil util = new BMRichUtil();
        Spanned test = util.createSpan(textDomObject.getAttrs(), textDomObject.getStyles());
        SpannableString spannableString = ((SpannableString) test);
        Object[] spans = spannableString.getSpans(0, spannableString.length(), Object.class);
        for (Object span : spans) {
            mSpans.add(new RichTextDomObject.BMRichSpan(span, mText.length(), spannableString.length() + mText.length()));
        }
        // 设置span的事件
        WXEvent events = object.getEvents();
        for (String event : events) {
            appendChildEvent(event, spannableString, textDomObject);
        }
        mText.append(spannableString.toString());
        spannableStringBuilder.append(spannableString);
    }
    update();
}
Also used : SpannableString(android.text.SpannableString) RichTextDomObject(com.taobao.weex.dom.RichTextDomObject) WXEvent(com.taobao.weex.dom.WXEvent) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject) WXDomObject(com.taobao.weex.dom.WXDomObject) ImmutableDomObject(com.taobao.weex.dom.ImmutableDomObject) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject) RichTextDomObject(com.taobao.weex.dom.RichTextDomObject) JSONObject(com.alibaba.fastjson.JSONObject) SpannableString(android.text.SpannableString) BMRichUtil(com.eros.framework.utils.BMRichUtil) Spanned(android.text.Spanned)

Aggregations

SpannableString (android.text.SpannableString)2 Spanned (android.text.Spanned)2 JSONObject (com.alibaba.fastjson.JSONObject)2 BMRichUtil (com.eros.framework.utils.BMRichUtil)2 ImmutableDomObject (com.taobao.weex.dom.ImmutableDomObject)2 RichTextDomObject (com.taobao.weex.dom.RichTextDomObject)2 WXDomObject (com.taobao.weex.dom.WXDomObject)2 WXEvent (com.taobao.weex.dom.WXEvent)2 WXTextDomObject (com.taobao.weex.dom.WXTextDomObject)2