package com.vincent.template.recycler.adapter;

import android.content.Context;
import android.view.ViewGroup;

import com.vincent.template.recycler.MultiItemTypeSupport;
import com.vincent.template.recycler.ViewHolderHelper;

import java.util.List;

public abstract class MultiItemRecycleViewAdapter<T> extends CommonRecycleViewAdapter<T>
{

    protected MultiItemTypeSupport<T> mMultiItemTypeSupport;

    public MultiItemRecycleViewAdapter(Context context, List<T> datas,
                                       MultiItemTypeSupport<T> multiItemTypeSupport)
    {
        super(context, -1, datas);
        mMultiItemTypeSupport = multiItemTypeSupport;

        if (mMultiItemTypeSupport == null)
            throw new IllegalArgumentException("the mMultiItemTypeSupport can not be null.");
    }
    public MultiItemRecycleViewAdapter(Context context, MultiItemTypeSupport<T> multiItemTypeSupport)
    {
        super(context, -1);
        mMultiItemTypeSupport = multiItemTypeSupport;

        if (mMultiItemTypeSupport == null)
            throw new IllegalArgumentException("the mMultiItemTypeSupport can not be null.");
    }

    @Override
    public int getItemViewType(int position)
    {
        if (mMultiItemTypeSupport != null)
            return mMultiItemTypeSupport.getItemViewType(position, mDatas.get(position));
        return super.getItemViewType(position);
    }

    @Override
    public ViewHolderHelper onCreateViewHolder(ViewGroup parent, int viewType)
    {
        if (mMultiItemTypeSupport == null) return super.onCreateViewHolder(parent, viewType);

        int layoutId = mMultiItemTypeSupport.getLayoutId(viewType);
        ViewHolderHelper holder = ViewHolderHelper.get(mContext, null, parent, layoutId, -1);
        setListener(parent, holder, viewType);
        return holder;
    }

}

@@ -244,16 +244,311 @@
 .List;%0A%0A
+/**%0A * packageName:%09    com.vincent.template.recycler.adapter%0A * className:%09    MultiItemRecycleViewAdapter%0A * author:%09        Luoxiang%0A * time:%09        2017/6/8%0914:31%0A * desc:%09        %E5%A4%9A%E7%B1%BB%E5%9E%8B%E6%9D%A1%E7%9B%AE%0A *%0A * svnVersion:%0A * upDateAuthor:    Vincent%0A * upDate:          2017/6/8%0A * upDateDesc:      TODO%0A */%0A
 public a

change MultiItemRecycleViewAdapter