Search in sources :

Example 1 with BinderViewHolder

use of com.tmall.wireless.tangram.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.tangram.core.adapter.GroupBasicAdapter) BinderViewHolder(com.tmall.wireless.tangram.core.adapter.BinderViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Example 2 with BinderViewHolder

use of com.tmall.wireless.tangram.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.tangram.core.adapter.BinderViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Example 3 with BinderViewHolder

use of com.tmall.wireless.tangram.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.tangram.core.adapter.GroupBasicAdapter) BinderViewHolder(com.tmall.wireless.tangram.core.adapter.BinderViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Example 4 with BinderViewHolder

use of com.tmall.wireless.tangram.core.adapter.BinderViewHolder 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.tangram.core.adapter.GroupBasicAdapter) BinderViewHolder(com.tmall.wireless.tangram.core.adapter.BinderViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Example 5 with BinderViewHolder

use of com.tmall.wireless.tangram.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.tangram.core.adapter.BinderViewHolder) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)5 BinderViewHolder (com.tmall.wireless.tangram.core.adapter.BinderViewHolder)5 GroupBasicAdapter (com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter)3