Search in sources :

Example 36 with BaseCell

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

the class PojoDataParser method parseFooterCell.

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

Example 37 with BaseCell

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

the class TangramEngine method topPosition.

/**
 * {@inheritDoc}
 */
@Override
public void topPosition(Card card) {
    List<BaseCell> cells = card.getCells();
    if (cells.size() > 0) {
        BaseCell cell = cells.get(0);
        int pos = mGroupBasicAdapter.getComponents().indexOf(cell);
        if (pos > 0) {
            VirtualLayoutManager lm = getLayoutManager();
            View view = lm.findViewByPosition(pos);
            if (view != null) {
                int top = lm.getDecoratedTop(view);
                RecyclerView recyclerView = getContentView();
                if (recyclerView != null) {
                    recyclerView.scrollBy(0, top);
                }
            } else {
                RecyclerView recyclerView = getContentView();
                if (recyclerView != null) {
                    recyclerView.scrollToPosition(pos);
                }
            }
        }
    }
}
Also used : BaseCell(com.tmall.wireless.tangram3.structure.BaseCell) RecyclerView(android.support.v7.widget.RecyclerView) VirtualLayoutManager(com.alibaba.android.vlayout.VirtualLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 38 with BaseCell

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

the class TangramEngine method scrollToPosition.

/**
 * {@inheritDoc}
 */
@Override
public void scrollToPosition(Card card) {
    List<BaseCell> cells = card.getCells();
    if (cells.size() > 0) {
        BaseCell cell = cells.get(0);
        int pos = mGroupBasicAdapter.getComponents().indexOf(cell);
        if (pos > 0) {
            RecyclerView recyclerView = getContentView();
            if (recyclerView != null) {
                recyclerView.scrollToPosition(pos);
            }
        }
    }
}
Also used : BaseCell(com.tmall.wireless.tangram3.structure.BaseCell) RecyclerView(android.support.v7.widget.RecyclerView)

Example 39 with BaseCell

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

the class TangramEngine method removeBy.

/**
 * Remove cell at target position. TODO handle nested card
 *
 * @param position
 * @since 2.1.0
 */
public void removeBy(int position) {
    if (mGroupBasicAdapter != null) {
        if (position < mGroupBasicAdapter.getItemCount() && position >= 0) {
            BaseCell removeCell = mGroupBasicAdapter.getItemByPosition(position);
            removeBy(removeCell);
        }
    }
}
Also used : BaseCell(com.tmall.wireless.tangram3.structure.BaseCell)

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