Search in sources :

Example 1 with BinderViewHolder

use of com.tmall.wireless.tangram3.core.adapter.BinderViewHolder in project Tangram-Android by alibaba.

the class BannerView method recyclerView.

private void recyclerView(List<BinderViewHolder> cache) {
    if (!cache.isEmpty()) {
        RecyclerView.RecycledViewPool pool = cell.serviceManager.getService(RecyclerView.RecycledViewPool.class);
        for (int i = 0, size = cache.size(); i < size; i++) {
            BinderViewHolder viewHolder = cache.get(i);
            viewHolder.unbind();
            removeView(viewHolder.itemView);
            pool.putRecycledView(viewHolder);
        }
        cache.clear();
    }
}
Also used : BinderViewHolder(com.tmall.wireless.tangram3.core.adapter.BinderViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Example 2 with BinderViewHolder

use of com.tmall.wireless.tangram3.core.adapter.BinderViewHolder in project Tangram-Android by alibaba.

the class LinearScrollView method recycleView.

private void recycleView(@NonNull BaseCell cell) {
    if (!mViewHolders.isEmpty()) {
        RecyclerView.RecycledViewPool pool = cell.serviceManager.getService(RecyclerView.RecycledViewPool.class);
        for (int i = 0, size = mViewHolders.size(); i < size; i++) {
            BinderViewHolder viewHolder = mViewHolders.get(i);
            viewHolder.unbind();
            removeView(viewHolder.itemView);
            pool.putRecycledView(viewHolder);
        }
        mViewHolders.clear();
    }
}
Also used : BinderViewHolder(com.tmall.wireless.tangram3.core.adapter.BinderViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Example 3 with BinderViewHolder

use of com.tmall.wireless.tangram3.core.adapter.BinderViewHolder in project Tangram-Android by alibaba.

the class PojoGroupBasicAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(BinderViewHolder<BaseCell, ? extends View> holder, int position) {
    super.onBindViewHolder(holder, position);
    int idx = findCardIdxFor(position);
    if (idx >= 0) {
        Pair<Range<Integer>, Card> pair = mCards.get(idx);
        pair.second.onBindCell(position - pair.first.getLower(), position, mLastBindPosition < 0 || mLastBindPosition < position);
        PageDetectorSupport pageDetectorSupport = pair.second.serviceManager.getService(PageDetectorSupport.class);
        if (pageDetectorSupport != null) {
            pageDetectorSupport.onBindItem(position, mLastBindPosition < 0 || mLastBindPosition < position, getItemByPosition(position));
        }
    }
    mLastBindPosition = position;
}
Also used : PageDetectorSupport(com.tmall.wireless.tangram3.support.PageDetectorSupport) Range(com.alibaba.android.vlayout.Range)

Example 4 with BinderViewHolder

use of com.tmall.wireless.tangram3.core.adapter.BinderViewHolder in project Tangram-Android by alibaba.

the class LinearScrollView method getViewFromRecycler.

private View getViewFromRecycler(@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);
    mViewHolders.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 5 with BinderViewHolder

use of com.tmall.wireless.tangram3.core.adapter.BinderViewHolder in project Tangram-Android by alibaba.

the class BannerView method getHeaderViewFromRecycler.

private View getHeaderViewFromRecycler(@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);
    mHeaderViewHolders.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)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)5 BinderViewHolder (com.tmall.wireless.tangram3.core.adapter.BinderViewHolder)5 GroupBasicAdapter (com.tmall.wireless.tangram3.core.adapter.GroupBasicAdapter)3 Range (com.alibaba.android.vlayout.Range)1 PageDetectorSupport (com.tmall.wireless.tangram3.support.PageDetectorSupport)1