Search in sources :

Example 26 with BaseCell

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

the class BannerView method postBindView.

@Override
public void postBindView(BaseCell cell) {
    getContext().registerReceiver(mScreenBroadcastReceiver, filter);
    BannerCell bannerCell = (BannerCell) cell;
    bannerCell.initAdapter();
    if (cell.style != null) {
        setPadding(cell.style.padding[3], cell.style.padding[0], cell.style.padding[1], cell.style.padding[2]);
    }
    setBackgroundColor(bannerCell.mBgColor);
    setAdapter(bannerCell.mBannerWrapper);
    mUltraViewPager.setAutoMeasureHeight(true);
    this.ratio = bannerCell.mRatio;
    this.height = bannerCell.height;
    mUltraViewPager.setRatio(this.ratio);
    setAutoScroll(bannerCell.mAutoScrollInternal, bannerCell.mSpecialInterval);
    mUltraViewPager.setPageMargin(bannerCell.hGap);
    if (bannerCell.mCells.size() <= bannerCell.mInfiniteMinCount) {
        setInfiniteLoop(false);
    } else {
        setInfiniteLoop(bannerCell.mInfinite);
    }
    setIndicatorGravity(getIndicatorGravity(bannerCell.mIndicatorGravity));
    setIndicatorPos(bannerCell.mIndicatorPos);
    int indicatorGap = bannerCell.mIndicatorGap;
    if (indicatorGap < 0) {
        indicatorGap = mIndicatorGap;
    }
    setIndicatorGap(indicatorGap);
    int indicatorMargin = bannerCell.mIndicatorMargin;
    if (indicatorMargin <= 0) {
        indicatorMargin = mIndicatorMargin;
    }
    setIndicatorMargin(indicatorMargin);
    int indicatorHeight = bannerCell.mIndicatorHeight;
    setIndicatorHeight(indicatorHeight);
    if (bannerCell.itemMargin[0] > 0 || bannerCell.itemMargin[1] > 0) {
        setScrollMargin(bannerCell.itemMargin[0], bannerCell.itemMargin[1]);
        mUltraViewPager.setClipToPadding(false);
        mUltraViewPager.setClipChildren(false);
    } else {
        setScrollMargin(0, 0);
        mUltraViewPager.setClipToPadding(true);
        mUltraViewPager.setClipChildren(true);
    }
    VirtualLayoutManager.LayoutParams layoutParams = (VirtualLayoutManager.LayoutParams) getLayoutParams();
    layoutParams.setMargins(bannerCell.margin[3], bannerCell.margin[0], bannerCell.margin[1], bannerCell.margin[2]);
    mUltraViewPager.setItemRatio(bannerCell.itemRatio);
    currentItemPos = bannerCell.extras.getIntValue(CURRENT_POS);
    mUltraViewPager.setCurrentItem(currentItemPos);
    updateIndicators(bannerCell.mIndicatorFocus, bannerCell.mIndicatorNor, bannerCell.mIndicatorRadius, bannerCell.mIndicatorColor, bannerCell.mIndicatorDefaultColor);
    recycleView();
    bindHeaderView(bannerCell.mHeader);
    bindFooterView(bannerCell.mFooter);
    if (cell.serviceManager != null) {
        bannerSupport = cell.serviceManager.getService(BannerSupport.class);
    }
}
Also used : BannerCell(com.tmall.wireless.tangram3.structure.cell.BannerCell) BannerSupport(com.tmall.wireless.tangram3.support.BannerSupport) VirtualLayoutManager(com.alibaba.android.vlayout.VirtualLayoutManager)

Example 27 with BaseCell

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

the class BannerView method getFooterViewFromRecycler.

private View getFooterViewFromRecycler(@NonNull BaseCell cell) {
    GroupBasicAdapter adapter = cell.serviceManager.getService(GroupBasicAdapter.class);
    RecyclerView.RecycledViewPool pool = cell.serviceManager.getService(RecyclerView.RecycledViewPool.class);
    int itemViewType = adapter.getItemType(cell);
    BinderViewHolder holder = (BinderViewHolder) pool.getRecycledView(itemViewType);
    if (holder == null) {
        holder = (BinderViewHolder) adapter.createViewHolder(this, itemViewType);
    }
    holder.bind(cell);
    mFooterViewHolders.add(holder);
    return holder.itemView;
}
Also used : GroupBasicAdapter(com.tmall.wireless.tangram3.core.adapter.GroupBasicAdapter) BinderViewHolder(com.tmall.wireless.tangram3.core.adapter.BinderViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Example 28 with BaseCell

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

the class LinearScrollCell method setCells.

public void setCells(List<BaseCell> cells) {
    if (adapter == null) {
        adapter = new Adapter(getAdapter());
    }
    this.cells.clear();
    if (cells != null && cells.size() > 0) {
        this.cells.addAll(cells);
    }
    adapter.notifyDataSetChanged();
}
Also used : GroupBasicAdapter(com.tmall.wireless.tangram3.core.adapter.GroupBasicAdapter)

Example 29 with BaseCell

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

the class TangramEngine method updateCard.

public void updateCard(Card card) {
    if (card != null && mGroupBasicAdapter != null) {
        Range<Integer> cardRange = mGroupBasicAdapter.getCardRange(card);
        for (int i = cardRange.getLower(); i < cardRange.getUpper(); i++) {
            BaseCell cell = mGroupBasicAdapter.getItemByPosition(i);
            cell.extras.put("_flag_invalidate_", true);
        }
        mGroupBasicAdapter.notifyItemRangeChanged(cardRange.getLower(), cardRange.getUpper());
    }
}
Also used : BaseCell(com.tmall.wireless.tangram3.structure.BaseCell)

Example 30 with BaseCell

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

the class MVHelper method unMountView.

public void unMountView(BaseCell cell, View view) {
    renderManager.unmountView(cell, view);
    if (cell.serviceManager != null) {
        if (cell.serviceManager.supportRx()) {
            cell.emitNext(BDE.UNBIND);
        }
    }
    postUnMountView(cell, view);
    if (cell.serviceManager != null) {
        CellSupport cellSupport = cell.serviceManager.getService(CellSupport.class);
        if (cellSupport != null) {
            cellSupport.unBindView(cell, view);
        }
    }
}
Also used : CellSupport(com.tmall.wireless.tangram3.support.CellSupport)

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