Search in sources :

Example 31 with BaseCell

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

the class MVHelper method postMountView.

private void postMountView(BaseCell cell, View view) {
    if (!cell.mIsExposed && cell.serviceManager != null) {
        ExposureSupport exposureSupport = cell.serviceManager.getService(ExposureSupport.class);
        if (exposureSupport != null) {
            cell.mIsExposed = true;
            exposureSupport.onExposure(view, cell, cell.pos);
        }
    }
    if (view instanceof ITangramViewLifeCycle) {
        ((ITangramViewLifeCycle) view).postBindView(cell);
    } else {
        if (postBindMap.get(cell) != null) {
            try {
                postBindMap.get(cell).invoke(view, cell);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : ExposureSupport(com.tmall.wireless.tangram3.support.ExposureSupport) ITangramViewLifeCycle(com.tmall.wireless.tangram3.structure.view.ITangramViewLifeCycle)

Example 32 with BaseCell

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

the class MVHelper method mountView.

public void mountView(BaseCell cell, View view) {
    try {
        mvResolver.register(cell, view);
        if (view.getTag(R.id.TANGRAM_ENGINE_TAG) == null) {
            view.setTag(R.id.TANGRAM_ENGINE_TAG, engineTag);
        }
        if (cell.serviceManager != null) {
            if (cell.serviceManager.supportRx()) {
                cell.emitNext(BDE.BIND);
            }
            CellSupport cellSupport = cell.serviceManager.getService(CellSupport.class);
            if (cellSupport != null) {
                cellSupport.bindView(cell, view);
            }
        }
        boolean renderServiceSuccess = renderManager.mountView(cell, view);
        if (!renderServiceSuccess) {
            initView(cell, view);
        }
        renderStyle(cell, view);
        postMountView(cell, view);
        if (cell.serviceManager != null) {
            CellSupport cellSupport = cell.serviceManager.getService(CellSupport.class);
            if (cellSupport != null) {
                cellSupport.postBindView(cell, view);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (cell.serviceManager != null) {
            CellSupport cellSupport = cell.serviceManager.getService(CellSupport.class);
            if (cellSupport != null) {
                cellSupport.onBindViewException(cell, view, e);
            }
        }
    }
}
Also used : CellSupport(com.tmall.wireless.tangram3.support.CellSupport)

Example 33 with BaseCell

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

the class PojoDataParser method parseCell.

protected void parseCell(BaseCell cell, JSONObject json) {
    if (json != null) {
        cell.extras = json;
        cell.id = json.getString(KEY_BIZ_ID);
        if (TextUtils.isEmpty(cell.id) && json.containsKey(KEY_ID)) {
            cell.id = json.getString(KEY_ID);
        }
        cell.stringType = parseCellType(json);
        cell.typeKey = json.getString(KEY_TYPE_KEY);
        String reuseId = json.getString(KEY_TYPE_REUSEID);
        if (!TextUtils.isEmpty(reuseId)) {
            cell.typeKey = reuseId;
        }
        Integer position = json.getInteger(KEY_POSITION);
        if (position == null) {
            position = -1;
        }
        cell.position = position;
        JSONObject styleJson = json.getJSONObject(KEY_STYLE);
        Style style = new Style();
        cell.style = parseStyle(style, styleJson);
    } else {
        cell.extras = new JSONObject();
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) ColumnStyle(com.tmall.wireless.tangram3.structure.style.ColumnStyle)

Example 34 with BaseCell

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

the class PojoDataParser method parseCard.

protected void parseCard(Card card, JSONObject data, ServiceManager serviceManager, Map<String, ComponentInfo> componentInfoMap) {
    card.id = data.getString(KEY_ID);
    if (card.id == null) {
        card.id = "";
    }
    // parsing header
    JSONObject header = data.getJSONObject(KEY_HEADER);
    BaseCell headerCell = parseSingleComponent(header, card, serviceManager, componentInfoMap);
    parseHeaderCell(headerCell, card);
    // parsing body
    JSONArray componentArray = data.getJSONArray(KEY_ITEMS);
    if (componentArray != null) {
        final int cellLength = componentArray.size();
        for (int i = 0; i < cellLength; i++) {
            final JSONObject cellData = componentArray.getJSONObject(i);
            parseSingleComponent(cellData, card, card.serviceManager, componentInfoMap);
        }
    }
    // parsing footer
    JSONObject footer = data.getJSONObject(KEY_FOOTER);
    BaseCell footerCell = parseSingleComponent(footer, card, serviceManager, componentInfoMap);
    parseFooterCell(footerCell, card);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) BaseCell(com.tmall.wireless.tangram3.structure.BaseCell) JSONArray(com.alibaba.fastjson.JSONArray)

Example 35 with BaseCell

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

the class PojoDataParser method parseHeaderCell.

protected void parseHeaderCell(BaseCell headerCell, Card card) {
    card.mHeader = headerCell;
    if (card instanceof GridCard) {
        GridCard gridCard = (GridCard) card;
        gridCard.ensureBlock(card.mHeader);
    } else if (card instanceof OnePlusNCard) {
        OnePlusNCard onePlusNCard = (OnePlusNCard) card;
        onePlusNCard.ensureBlock(card.mHeader);
    }
}
Also used : GridCard(com.tmall.wireless.tangram3.structure.card.GridCard) OnePlusNCard(com.tmall.wireless.tangram3.structure.card.OnePlusNCard)

Aggregations

BaseCell (com.tmall.wireless.tangram3.structure.BaseCell)21 RecyclerView (android.support.v7.widget.RecyclerView)7 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)5 ArrayList (java.util.ArrayList)5 Range (com.alibaba.android.vlayout.Range)4 JSONObject (com.alibaba.fastjson.JSONObject)4 BinderViewHolder (com.tmall.wireless.tangram3.core.adapter.BinderViewHolder)4 GroupBasicAdapter (com.tmall.wireless.tangram3.core.adapter.GroupBasicAdapter)4 Card (com.tmall.wireless.tangram3.dataparser.concrete.Card)4 GridCard (com.tmall.wireless.tangram3.structure.card.GridCard)4 OnePlusNCard (com.tmall.wireless.tangram3.structure.card.OnePlusNCard)4 NonNull (android.support.annotation.NonNull)3 LayoutHelper (com.alibaba.android.vlayout.LayoutHelper)3 ColumnStyle (com.tmall.wireless.tangram3.structure.style.ColumnStyle)3 CellSupport (com.tmall.wireless.tangram3.support.CellSupport)3 Pair (android.util.Pair)2 View (android.view.View)2 JSONArray (com.alibaba.fastjson.JSONArray)2 MVHelper (com.tmall.wireless.tangram3.MVHelper)2 BannerCard (com.tmall.wireless.tangram3.structure.card.BannerCard)2