Search in sources :

Example 26 with BaseCell

use of com.tmall.wireless.tangram.structure.BaseCell in project Tangram-Android by alibaba.

the class LinearScrollEntityCard method parseWith.

@Override
public void parseWith(@NonNull JSONObject data, @NonNull MVHelper resolver) {
    this.cells.clear();
    id = data.optString(Card.KEY_ID, id == null ? "" : id);
    this.cardType = data.optString(Card.KEY_TYPE);
    // parsing header
    JSONObject header = data.optJSONObject(Card.KEY_HEADER);
    parseHeaderCell(resolver, header);
    // parsing body
    JSONArray componentArray = data.optJSONArray(Card.KEY_ITEMS);
    if (componentArray != null) {
        final int cellLength = componentArray.length();
        for (int i = 0; i < cellLength; i++) {
            final JSONObject cellData = componentArray.optJSONObject(i);
            BaseCell cell = createCell(resolver, cellData, true);
            try {
                if (cell != null) {
                    cell.extras.put(MVResolver.KEY_INDEX, cell.pos);
                }
            } catch (JSONException e) {
            }
        }
    }
    // parsing footer
    JSONObject footer = data.optJSONObject(Card.KEY_FOOTER);
    parseFooterCell(resolver, footer);
    JSONObject styleJson = data.optJSONObject(Card.KEY_STYLE);
    parseStyle(styleJson);
}
Also used : JSONObject(org.json.JSONObject) BaseCell(com.tmall.wireless.tangram.structure.BaseCell) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Aggregations

BaseCell (com.tmall.wireless.tangram.structure.BaseCell)26 JSONObject (org.json.JSONObject)5 Card (com.tmall.wireless.tangram.dataparser.concrete.Card)3 JSONArray (org.json.JSONArray)3 JSONException (org.json.JSONException)3 Nullable (android.support.annotation.Nullable)2 View (android.view.View)2 LayoutHelper (com.alibaba.android.vlayout.LayoutHelper)2 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)2 MVHelper (com.tmall.wireless.tangram.MVHelper)2 BaseCellBinderResolver (com.tmall.wireless.tangram.dataparser.concrete.BaseCellBinderResolver)2 BannerEntityCard (com.tmall.wireless.tangram.structure.entitycard.BannerEntityCard)2 LinearScrollEntityCard (com.tmall.wireless.tangram.structure.entitycard.LinearScrollEntityCard)2 ArrayList (java.util.ArrayList)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ViewGroup (android.view.ViewGroup)1 Range (com.alibaba.android.vlayout.Range)1 OnePlusNLayoutHelper (com.alibaba.android.vlayout.layout.OnePlusNLayoutHelper)1 Engine (com.tmall.wireless.tangram.Engine)1