Search in sources :

Example 1 with Style

use of com.tmall.wireless.tangram.dataparser.concrete.Style in project Tangram-Android by alibaba.

the class BannerEntityCard method parseStyle.

@Override
public void parseStyle(@Nullable JSONObject data) {
    style = new Style();
    style.parseWith(data);
    setRatio(style.aspectRatio);
    setBgColor(style.bgColor);
    margin = style.margin;
    if (margin != null) {
        for (int i = 0; i < margin.length; i++) {
            if (margin[i] < 0) {
                margin[i] = 0;
            }
        }
    }
    height = style.height;
    if (data != null) {
        setIndicatorRadius(Style.parseSize(data.optString(BannerCard.ATTR_INDICATOR_RADIUS), 0));
        setIndicatorColor(Style.parseColor(data.optString(BannerCard.ATTR_INDICATOR_COLOR, "#00000000")));
        setIndicatorDefaultColor(Style.parseColor(data.optString(BannerCard.ATTR_INDICATOR_DEFAULT_INDICATOR_COLOR, "#00000000")));
        setAutoScrollInternal(data.optInt(BannerCard.ATTR_AUTOSCROLL));
        setSpecialInterval(data.optJSONObject(BannerCard.ATTR_SPECIAL_INTERVAL));
        setInfinite(data.optBoolean(BannerCard.ATTR_INFINITE));
        setInfiniteMinCount(data.optInt(BannerCard.ATTR_INFINITE_MIN_COUNT));
        setIndicatorFocus(data.optString(BannerCard.ATTR_INDICATOR_FOCUS));
        setIndicatorNor(data.optString(BannerCard.ATTR_INDICATOR_NORMAL));
        setIndicatorGravity(data.optString(BannerCard.ATTR_INDICATOR_GRA));
        setIndicatorPos(data.optString(BannerCard.ATTR_INDICATOR_POS));
        setIndicatorGap(Style.parseSize(data.optString(BannerCard.ATTR_INDICATOR_GAP), 0));
        setIndicatorMargin(Style.parseSize(data.optString(BannerCard.ATTR_INDICATOR_MARGIN), 0));
        setIndicatorHeight(Style.parseSize(data.optString(BannerCard.ATTR_INDICATOR_HEIGHT), 0));
        setPageWidth(data.optDouble(BannerCard.ATTR_PAGE_WIDTH));
        sethGap(Style.parseSize(data.optString(BannerCard.ATTR_HGAP), 0));
        itemMargin[0] = Style.parseSize(data.optString(BannerCard.ATTR_ITEM_MARGIN_LEFT), 0);
        itemMargin[1] = Style.parseSize(data.optString(BannerCard.ATTR_ITEM_MARGIN_RIGHT), 0);
        itemRatio = data.optDouble(BannerCard.ATTR_ITEM_RATIO, Double.NaN);
    }
}
Also used : Style(com.tmall.wireless.tangram.dataparser.concrete.Style)

Example 2 with Style

use of com.tmall.wireless.tangram.dataparser.concrete.Style in project Tangram-Android by alibaba.

the class LinearScrollEntityCard method parseStyle.

@Override
public void parseStyle(@Nullable JSONObject data) {
    style = new Style();
    style.parseWith(data);
    if (data != null) {
        pageWidth = Style.parseSize(optStringParam(LinearScrollCell.KEY_PAGE_WIDTH), 0);
        pageHeight = Style.parseSize(optStringParam(LinearScrollCell.KEY_PAGE_HEIGHT), 0);
        defaultIndicatorColor = parseColor(optStringParam(LinearScrollCell.KEY_DEFAULT_INDICATOR_COLOR), LinearScrollCell.DEFAULT_DEFAULT_INDICATOR_COLOR);
        indicatorColor = parseColor(optStringParam(LinearScrollCell.KEY_INDICATOR_COLOR), LinearScrollCell.DEFAULT_INDICATOR_COLOR);
        if (data.has(LinearScrollCell.KEY_HAS_INDICATOR)) {
            hasIndicator = data.optBoolean(LinearScrollCell.KEY_HAS_INDICATOR);
        }
        if (data.has(LinearScrollCell.KEY_FOOTER_TYPE)) {
            footerType = data.optString(LinearScrollCell.KEY_FOOTER_TYPE);
        }
        bgColor = parseColor(data.optString(Style.KEY_BG_COLOR), Color.TRANSPARENT);
        retainScrollState = data.optBoolean(LinearScrollCell.KEY_RETAIN_SCROLL_STATE, true);
        scrollMarginLeft = Style.parseSize(data.optString(LinearScrollCell.KEY_SCROLL_MARGIN_LEFT), 0);
        scrollMarginRight = Style.parseSize(data.optString(LinearScrollCell.KEY_SCROLL_MARGIN_RIGHT), 0);
    }
}
Also used : Style(com.tmall.wireless.tangram.dataparser.concrete.Style)

Example 3 with Style

use of com.tmall.wireless.tangram.dataparser.concrete.Style in project Tangram-Android by alibaba.

the class MVResolver method parseStyle.

protected void parseStyle(BaseCell cell, @Nullable JSONObject json) {
    if (!Utils.isCard(cell.extras)) {
        cell.style = new Style();
        if (json != null) {
            cell.style.parseWith(json);
            cell.parseStyle(json);
        }
    }
}
Also used : Style(com.tmall.wireless.tangram.dataparser.concrete.Style)

Example 4 with Style

use of com.tmall.wireless.tangram.dataparser.concrete.Style in project Tangram-Android by alibaba.

the class GridCard method convertChildLayoutHelper.

private void convertChildLayoutHelper(@Nullable RangeGridLayoutHelper gridHelper, GridCard parentCard) {
    for (int i = 0, size = parentCard.getChildren().size(); i < size; i++) {
        Range<Integer> range = parentCard.getChildren().keyAt(i);
        Card child = parentCard.getChildren().valueAt(i);
        Style style = child.style;
        if (style instanceof GridStyle && child instanceof GridCard) {
            final GridStyle gridStyle = (GridStyle) style;
            final GridCard gridCard = (GridCard) child;
            if (!gridCard.getChildren().isEmpty()) {
                convertChildLayoutHelper(gridHelper, gridCard);
            }
            GridRangeStyle rangeStyle = new GridRangeStyle();
            int totalColumn = gridCard.mColumn;
            if (gridStyle.column > 0) {
                totalColumn = gridStyle.column;
                rangeStyle.setSpanCount(gridStyle.column);
            } else {
                rangeStyle.setSpanCount(totalColumn);
            }
            rangeStyle.setSpanSizeLookup(new CellSpanSizeLookup(gridCard.getCells(), totalColumn));
            rangeStyle.setVGap(gridStyle.vGap);
            rangeStyle.setHGap(gridStyle.hGap);
            rangeStyle.setAutoExpand(gridStyle.autoExpand);
            if (gridStyle.cols != null && gridStyle.cols.length > 0) {
                rangeStyle.setWeights(gridStyle.cols);
            }
            if (!Float.isNaN(gridStyle.aspectRatio)) {
                rangeStyle.setAspectRatio(gridStyle.aspectRatio);
            }
            rangeStyle.setBgColor(style.bgColor);
            rangeStyle.setMargin(style.margin[Style.MARGIN_LEFT_INDEX], style.margin[Style.MARGIN_TOP_INDEX], style.margin[Style.MARGIN_RIGHT_INDEX], style.margin[Style.MARGIN_BOTTOM_INDEX]);
            rangeStyle.setPadding(style.padding[Style.MARGIN_LEFT_INDEX], style.padding[Style.MARGIN_TOP_INDEX], style.padding[Style.MARGIN_RIGHT_INDEX], style.padding[Style.MARGIN_BOTTOM_INDEX]);
            if (!TextUtils.isEmpty(style.bgImgUrl)) {
                if (serviceManager != null && serviceManager.getService(CardSupport.class) != null) {
                    final CardSupport support = serviceManager.getService(CardSupport.class);
                    rangeStyle.setLayoutViewBindListener(new BindListener(style) {

                        @Override
                        public void onBind(View layoutView, BaseLayoutHelper baseLayoutHelper) {
                            support.onBindBackgroundView(layoutView, gridCard);
                        }
                    });
                    rangeStyle.setLayoutViewUnBindListener(new UnbindListener(style) {

                        @Override
                        public void onUnbind(View layoutView, BaseLayoutHelper baseLayoutHelper) {
                            support.onUnbindBackgroundView(layoutView, gridCard);
                        }
                    });
                } else {
                    rangeStyle.setLayoutViewBindListener(new BindListener(style));
                    rangeStyle.setLayoutViewUnBindListener(new UnbindListener(style));
                }
            } else {
                rangeStyle.setLayoutViewBindListener(null);
                rangeStyle.setLayoutViewUnBindListener(null);
            }
            gridHelper.addRangeStyle(range.getLower().intValue(), range.getUpper().intValue(), rangeStyle);
        }
    }
}
Also used : View(android.view.View) Card(com.tmall.wireless.tangram.dataparser.concrete.Card) CardSupport(com.tmall.wireless.tangram.support.CardSupport) Style(com.tmall.wireless.tangram.dataparser.concrete.Style) GridRangeStyle(com.alibaba.android.vlayout.layout.RangeGridLayoutHelper.GridRangeStyle) GridRangeStyle(com.alibaba.android.vlayout.layout.RangeGridLayoutHelper.GridRangeStyle) BaseLayoutHelper(com.alibaba.android.vlayout.layout.BaseLayoutHelper)

Example 5 with Style

use of com.tmall.wireless.tangram.dataparser.concrete.Style in project Tangram-Android by alibaba.

the class VVCard method parseWith.

@Override
public void parseWith(@NonNull JSONObject data, @NonNull MVHelper resolver) {
    maxChildren = 1;
    this.extras = data;
    this.stringType = data.optString(KEY_TYPE);
    id = data.optString(KEY_ID, id == null ? "" : id);
    loadMore = data.optInt(KEY_LOAD_TYPE, 0) == LOAD_TYPE_LOADMORE;
    // you should alway assign hasMore to indicate there's more data explicitly
    if (data.has(KEY_HAS_MORE)) {
        hasMore = data.optBoolean(KEY_HAS_MORE);
    } else {
        if (data.has(KEY_LOAD_TYPE)) {
            hasMore = data.optInt(KEY_LOAD_TYPE) == LOAD_TYPE_LOADMORE;
        }
    }
    load = data.optString(KEY_API_LOAD, null);
    loadParams = data.optJSONObject(KEY_API_LOAD_PARAMS);
    loaded = data.optBoolean(KEY_LOADED, false);
    createCell(resolver, extras, true);
    // do not need parse style, leave style empty
    this.extras.remove(KEY_STYLE);
    style = new Style();
}
Also used : Style(com.tmall.wireless.tangram.dataparser.concrete.Style)

Aggregations

Style (com.tmall.wireless.tangram.dataparser.concrete.Style)6 View (android.view.View)1 BaseLayoutHelper (com.alibaba.android.vlayout.layout.BaseLayoutHelper)1 GridRangeStyle (com.alibaba.android.vlayout.layout.RangeGridLayoutHelper.GridRangeStyle)1 Card (com.tmall.wireless.tangram.dataparser.concrete.Card)1 CardSupport (com.tmall.wireless.tangram.support.CardSupport)1