Search in sources :

Example 1 with GroupBasicAdapter

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

the class BannerCell method initAdapter.

public void initAdapter() {
    if (mBannerAdapter == null) {
        if (serviceManager != null) {
            GroupBasicAdapter adapter = serviceManager.getService(GroupBasicAdapter.class);
            RecyclerView.RecycledViewPool pool = serviceManager.getService(RecyclerView.RecycledViewPool.class);
            mBannerAdapter = new BannerAdapter(adapter, pool);
        }
    }
    if (mBannerWrapper == null) {
        mBannerWrapper = new UltraViewPagerAdapter(mBannerAdapter);
    }
}
Also used : GroupBasicAdapter(com.tmall.wireless.tangram3.core.adapter.GroupBasicAdapter) RecyclerView(android.support.v7.widget.RecyclerView) UltraViewPagerAdapter(com.tmall.ultraviewpager.UltraViewPagerAdapter)

Example 2 with GroupBasicAdapter

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

the class BaseTangramEngine method bindView.

/**
 * Bind a recyclerView to Tangram. After calling this, {@link GroupBasicAdapter}, {@link VirtualLayoutManager} are auto binded.
 *
 * @param view A plain recyclerView with no adapter or layoutManager binded.
 */
public void bindView(@NonNull final RecyclerView view) {
    // noinspection ConstantConditions
    Preconditions.checkArgument(view != null, "view must not be null");
    if (mContentView != null) {
        mContentView.setAdapter(null);
        mContentView.setLayoutManager(null);
    }
    this.mContentView = view;
    this.mContentView.setLayoutManager(mLayoutManager);
    mLayoutManager.setPerformanceMonitor(mPerformanceMonitor);
    if (mGroupBasicAdapter == null) {
        this.mGroupBasicAdapter = mAdapterBuilder.newAdapter(mContext, mLayoutManager, this);
        mGroupBasicAdapter.setPerformanceMonitor(mPerformanceMonitor);
        mGroupBasicAdapter.setErrorSupport(getService(InternalErrorSupport.class));
    }
    if (mContentView.getRecycledViewPool() != null) {
        mContentView.setRecycledViewPool(new InnerRecycledViewPool(mContentView.getRecycledViewPool()));
    }
    register(GroupBasicAdapter.class, mGroupBasicAdapter);
    register(RecyclerView.RecycledViewPool.class, mContentView.getRecycledViewPool());
    this.mContentView.setAdapter(mGroupBasicAdapter);
    if (VERSION.SDK_INT < 21) {
        this.mContentView.setChildDrawingOrderCallback(new DrawingOrderCallback());
    }
}
Also used : InternalErrorSupport(com.tmall.wireless.tangram3.support.InternalErrorSupport) InnerRecycledViewPool(com.alibaba.android.vlayout.extend.InnerRecycledViewPool) RecyclerView(android.support.v7.widget.RecyclerView) ChildDrawingOrderCallback(android.support.v7.widget.RecyclerView.ChildDrawingOrderCallback)

Example 3 with GroupBasicAdapter

use of com.tmall.wireless.tangram3.core.adapter.GroupBasicAdapter 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 4 with GroupBasicAdapter

use of com.tmall.wireless.tangram3.core.adapter.GroupBasicAdapter 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)

Example 5 with GroupBasicAdapter

use of com.tmall.wireless.tangram3.core.adapter.GroupBasicAdapter 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)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)5 GroupBasicAdapter (com.tmall.wireless.tangram3.core.adapter.GroupBasicAdapter)4 BinderViewHolder (com.tmall.wireless.tangram3.core.adapter.BinderViewHolder)3 ChildDrawingOrderCallback (android.support.v7.widget.RecyclerView.ChildDrawingOrderCallback)1 InnerRecycledViewPool (com.alibaba.android.vlayout.extend.InnerRecycledViewPool)1 UltraViewPagerAdapter (com.tmall.ultraviewpager.UltraViewPagerAdapter)1 InternalErrorSupport (com.tmall.wireless.tangram3.support.InternalErrorSupport)1