// Path: library/src/main/java/com/steve/creact/library/display/CommonDisplayBean.java
// public class CommonDisplayBean extends BaseDisplayBean<BaseRecyclerViewHolder> {
//     private int layoutId;
// 
//     public CommonDisplayBean(int layoutId) {
//         this.layoutId = layoutId;
//     }
// 
//     @Override
//     public BaseRecyclerViewHolder createHolder(ViewGroup parent) {
//         return new BaseRecyclerViewHolder(getView(parent, layoutId)){
// 
//             @Override
//             public void setData(Object data) {
//                 //do nothing
//             }
//         };
//     }
// }
// 
// Path: library/src/main/java/com/steve/creact/library/display/DataBean.java
// public interface DataBean<T,VH extends BaseRecyclerViewHolder> extends DisplayBean<VH> {
//     void bindData(VH holder);
//     T getData();
// }
// 
// Path: library/src/main/java/com/steve/creact/library/display/DisplayBean.java
// public interface DisplayBean<VH extends BaseRecyclerViewHolder> {
// 
//     VH createHolder(ViewGroup parent);
// }
// 
// Path: library/src/main/java/com/steve/creact/library/viewholder/BaseRecyclerViewHolder.java
// public abstract class BaseRecyclerViewHolder<D> extends RecyclerView.ViewHolder implements HolderAPI {
// 
//   protected final HolderAPI holderAPI;
// 
//   public BaseRecyclerViewHolder( View itemView ) {
//     super( itemView );
//     holderAPI = new HolderHelper( itemView );
//     initView();
//   }
// 
//   @Override
//   public Context getContext() {
//     return holderAPI.getContext();
//   }
// 
//   @Override
//   public void setOnItemClickListener( View.OnClickListener listener ) {
//     holderAPI.setOnItemClickListener( listener );
//   }
// 
//   /**
//    * Notes:when you remove a view,you must remove it from cache
//    *
//    * @param id
//    */
//   @Override
//   public void removeFromCache( @IdRes int id ) {
//     holderAPI.removeFromCache( id );
//   }
// 
//   /**
//    * remove all views in cache
//    */
//   @Override
//   public void removeAll() {
//     holderAPI.removeAll();
//   }
// 
//   /**
//    * subclass can overwrite this method
//    */
//   @Override
//   public void initView() {
//     holderAPI.initView();
//   }
// 
//   @Override
//   public <T extends View> T getView( @IdRes int id ) {
//     return holderAPI.getView( id );
//   }
// 
//   @Override
//   public void setText( @IdRes int id, CharSequence text ) {
//     holderAPI.setText( id, text );
//   }
// 
//   @Override
//   public void setTextWatcher( @IdRes int id, TextWatcherAdapter watcherAdapter ) {
//     holderAPI.setTextWatcher( id, watcherAdapter );
//   }
// 
//   @Override
//   public CharSequence getText( @IdRes int id ) {
//     return holderAPI.getText( id );
//   }
// 
//   @Override
//   public void setOnClickListener( @IdRes int id, View.OnClickListener onClickListener ) {
//     holderAPI.setOnClickListener( id, onClickListener );
//   }
// 
//   @Override
//   public void setOnLongClickListener( @IdRes int id, View.OnLongClickListener onLongClickListener ) {
//     holderAPI.setOnLongClickListener( id, onLongClickListener );
//   }
// 
//   @Override
//   public void setVisibility( @IdRes int id, int visibility ) {
//     holderAPI.setVisibility( id, visibility );
//   }
// 
//   @Override
//   public void setImageSrc( @IdRes int id, @DrawableRes int res ) {
//     holderAPI.setImageSrc( id, res );
//   }
// 
//   @Override
//   public void setImageDrawable( @IdRes int id, Drawable drawable ) {
//     holderAPI.setImageDrawable( id, drawable );
//   }
// 
//   @Override
//   public void setImageBitmap( @IdRes int id, Bitmap bitmap ) {
//     holderAPI.setImageBitmap( id, bitmap );
//   }
// 
//   public abstract void setData( D data );
// }


import android.view.ViewGroup;
import com.steve.creact.library.display.CommonDisplayBean;
import com.steve.creact.library.display.DataBean;
import com.steve.creact.library.display.DisplayBean;
import com.steve.creact.library.viewholder.BaseRecyclerViewHolder;
import java.util.ArrayList;
import java.util.List;
package com.steve.creact.library.adapter;




/**
 * A common adapter which extends from BaseRecyclerAdapter,can handle ViewHolder's creation
 * and bind data to ViewHolder.
 * <p/>
 * Use this class as your RecyclerView's adapter,it will do all tasks for you,
 * what you need to do is extending BaseRecyclerViewHolder,writing your custom ViewHolder class,
 * and extending  BaseDataBean ,writing your DataBean,or just using CommonDisplayBean.
 * <p/>
 * Alternatively,you can use @DataBean annotation(which can generate DataBean class at compiler time for you)
 * on your custom ViewHolder class
 *
 * @see DisplayBean
 * @see DataBean
 * @see CommonDisplayBean
 * @see BaseRecyclerViewHolder
 */
public class CommonRecyclerAdapter extends BaseRecyclerAdapter<DisplayBean, BaseRecyclerViewHolder> {
    private boolean userAnimation = false;
    //those bean instance will use to create concrete ViewHolders
    private List<DisplayBean> createBeans = new ArrayList<>();
    //those bean class will use to get correct item type
    private List<Class<DisplayBean>> createBeanClass = new ArrayList<>();

    //load data
    @Override
    public void loadData(List<? extends DisplayBean> dataSet) {
        if (dataSet == null || dataSet.size() == 0)
            return;
        for (int i = 0; i < dataSet.size(); i++) {
            DisplayBean bean = dataSet.get(i);
            if (!createBeanClass.contains(bean.getClass())) {
                addCreateBean(bean);
            }
        }
        super.loadData(dataSet);
    }


    @Override
    public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        DisplayBean createBean = createBeans.get(viewType);
        return createBean.createHolder(parent);
    }

    @Override
    public void onBindViewHolder(BaseRecyclerViewHolder holder, int position) {
        DisplayBean bindBean = data.get(position);
// Path: library/src/main/java/com/steve/creact/library/display/CommonDisplayBean.java
// public class CommonDisplayBean extends BaseDisplayBean<BaseRecyclerViewHolder> {
//     private int layoutId;
// 
//     public CommonDisplayBean(int layoutId) {
//         this.layoutId = layoutId;
//     }
// 
//     @Override
//     public BaseRecyclerViewHolder createHolder(ViewGroup parent) {
//         return new BaseRecyclerViewHolder(getView(parent, layoutId)){
// 
//             @Override
//             public void setData(Object data) {
//                 //do nothing
//             }
//         };
//     }
// }
// 
// Path: library/src/main/java/com/steve/creact/library/display/DataBean.java
// public interface DataBean<T,VH extends BaseRecyclerViewHolder> extends DisplayBean<VH> {
//     void bindData(VH holder);
//     T getData();
// }
// 
// Path: library/src/main/java/com/steve/creact/library/display/DisplayBean.java
// public interface DisplayBean<VH extends BaseRecyclerViewHolder> {
// 
//     VH createHolder(ViewGroup parent);
// }
// 
// Path: library/src/main/java/com/steve/creact/library/viewholder/BaseRecyclerViewHolder.java
// public abstract class BaseRecyclerViewHolder<D> extends RecyclerView.ViewHolder implements HolderAPI {
// 
//   protected final HolderAPI holderAPI;
// 
//   public BaseRecyclerViewHolder( View itemView ) {
//     super( itemView );
//     holderAPI = new HolderHelper( itemView );
//     initView();
//   }
// 
//   @Override
//   public Context getContext() {
//     return holderAPI.getContext();
//   }
// 
//   @Override
//   public void setOnItemClickListener( View.OnClickListener listener ) {
//     holderAPI.setOnItemClickListener( listener );
//   }
// 
//   /**
//    * Notes:when you remove a view,you must remove it from cache
//    *
//    * @param id
//    */
//   @Override
//   public void removeFromCache( @IdRes int id ) {
//     holderAPI.removeFromCache( id );
//   }
// 
//   /**
//    * remove all views in cache
//    */
//   @Override
//   public void removeAll() {
//     holderAPI.removeAll();
//   }
// 
//   /**
//    * subclass can overwrite this method
//    */
//   @Override
//   public void initView() {
//     holderAPI.initView();
//   }
// 
//   @Override
//   public <T extends View> T getView( @IdRes int id ) {
//     return holderAPI.getView( id );
//   }
// 
//   @Override
//   public void setText( @IdRes int id, CharSequence text ) {
//     holderAPI.setText( id, text );
//   }
// 
//   @Override
//   public void setTextWatcher( @IdRes int id, TextWatcherAdapter watcherAdapter ) {
//     holderAPI.setTextWatcher( id, watcherAdapter );
//   }
// 
//   @Override
//   public CharSequence getText( @IdRes int id ) {
//     return holderAPI.getText( id );
//   }
// 
//   @Override
//   public void setOnClickListener( @IdRes int id, View.OnClickListener onClickListener ) {
//     holderAPI.setOnClickListener( id, onClickListener );
//   }
// 
//   @Override
//   public void setOnLongClickListener( @IdRes int id, View.OnLongClickListener onLongClickListener ) {
//     holderAPI.setOnLongClickListener( id, onLongClickListener );
//   }
// 
//   @Override
//   public void setVisibility( @IdRes int id, int visibility ) {
//     holderAPI.setVisibility( id, visibility );
//   }
// 
//   @Override
//   public void setImageSrc( @IdRes int id, @DrawableRes int res ) {
//     holderAPI.setImageSrc( id, res );
//   }
// 
//   @Override
//   public void setImageDrawable( @IdRes int id, Drawable drawable ) {
//     holderAPI.setImageDrawable( id, drawable );
//   }
// 
//   @Override
//   public void setImageBitmap( @IdRes int id, Bitmap bitmap ) {
//     holderAPI.setImageBitmap( id, bitmap );
//   }
// 
//   public abstract void setData( D data );
// }


// Path: library/src/main/java/com/steve/creact/library/adapter/CommonRecyclerAdapter.java
import android.view.ViewGroup;
import com.steve.creact.library.display.CommonDisplayBean;
import com.steve.creact.library.display.DataBean;
import com.steve.creact.library.display.DisplayBean;
import com.steve.creact.library.viewholder.BaseRecyclerViewHolder;
import java.util.ArrayList;
import java.util.List;

package com.steve.creact.library.adapter;




/**
 * A common adapter which extends from BaseRecyclerAdapter,can handle ViewHolder's creation
 * and bind data to ViewHolder.
 * <p/>
 * Use this class as your RecyclerView's adapter,it will do all tasks for you,
 * what you need to do is extending BaseRecyclerViewHolder,writing your custom ViewHolder class,
 * and extending  BaseDataBean ,writing your DataBean,or just using CommonDisplayBean.
 * <p/>
 * Alternatively,you can use @DataBean annotation(which can generate DataBean class at compiler time for you)
 * on your custom ViewHolder class
 *
 * @see DisplayBean
 * @see DataBean
 * @see CommonDisplayBean
 * @see BaseRecyclerViewHolder
 */
public class CommonRecyclerAdapter extends BaseRecyclerAdapter<DisplayBean, BaseRecyclerViewHolder> {
    private boolean userAnimation = false;
    //those bean instance will use to create concrete ViewHolders
    private List<DisplayBean> createBeans = new ArrayList<>();
    //those bean class will use to get correct item type
    private List<Class<DisplayBean>> createBeanClass = new ArrayList<>();

    //load data
    @Override
    public void loadData(List<? extends DisplayBean> dataSet) {
        if (dataSet == null || dataSet.size() == 0)
            return;
        for (int i = 0; i < dataSet.size(); i++) {
            DisplayBean bean = dataSet.get(i);
            if (!createBeanClass.contains(bean.getClass())) {
                addCreateBean(bean);
            }
        }
        super.loadData(dataSet);
    }


    @Override
    public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        DisplayBean createBean = createBeans.get(viewType);
        return createBean.createHolder(parent);
    }

    @Override
    public void onBindViewHolder(BaseRecyclerViewHolder holder, int position) {
        DisplayBean bindBean = data.get(position);
        if (bindBean instanceof DataBean) {