package com.camnter.easyrecyclerviewtest.adapter;

import android.widget.ImageView;
import android.widget.TextView;

import com.camnter.easyrecyclerview.adapter.EasyRecyclerViewAdapter;
import com.camnter.easyrecyclerview.holder.EasyRecyclerViewHolder;
import com.camnter.easyrecyclerviewtest.R;
import com.camnter.easyrecyclerviewtest.bean.RecyclerViewData;


/**
 * Description：
 * Created by：CaMnter
 * Time：2015-10-21 17:00
 */
public class MyRecycleViewAdapter extends EasyRecyclerViewAdapter {

    private static final int MULTIPLE_ITEM_TYPE = 0;
    private static final int SINGLE_ITEM_TYPE = 1;

    /**
     * 请返回RecycleView加载的布局Id数组
     *
     * @return 布局Id数组
     */
    @Override
    public int[] getItemLayouts() {
        return new int[]{
                R.layout.item_recyclerview_multiple, R.layout.item_recyclerview_single};
    }

    /**
     * 对接了onBindViewHolder
     * onBindViewHolder里的逻辑写在这
     *
     * @param viewHolder
     * @param position
     */
    @Override
    public void onBindRecycleViewHolder(EasyRecyclerViewHolder viewHolder, int position) {
        int itemType = this.getRecycleViewItemType(position);
        RecyclerViewData data = this.getItem(position);
        switch (itemType) {
            case MULTIPLE_ITEM_TYPE: {
                TextView multipleTV = viewHolder.findViewById(R.id.recycler_view_mul_tv);
                ImageView multipleIV = viewHolder.findViewById(R.id.recycler_view_mul_iv);
                multipleTV.setText(data.content);
                multipleIV.setImageResource(data.imageResId);
                break;
            }
            case SINGLE_ITEM_TYPE: {
                ImageView singleIV = viewHolder.findViewById(R.id.recycler_view_single_iv);
                singleIV.setImageResource(data.imageResId);
                break;
            }
        }
    }

    /**
     * 如果是多布局的话，请写判断逻辑
     * 单布局可以不写
     *
     * @param position Item position
     * @return 布局Id数组中的index
     */
    @Override
    public int getRecycleViewItemType(int position) {
        if (position % 2 == 0) {
            return SINGLE_ITEM_TYPE;
        } else {
            return MULTIPLE_ITEM_TYPE;
        }
    }

}

@@ -599,24 +599,25 @@
 E = 1;%0A%0A
+%0A
     /**%0A
      * %E8%AF%B7
@@ -604,24 +604,82 @@
 ;%0A%0A%0A    /**%0A
+     * Please return RecyclerView loading layout Id array%0A
      * %E8%AF%B7%E8%BF%94%E5%9B%9ERe
@@ -679,24 +679,25 @@
 * %E8%AF%B7%E8%BF%94%E5%9B%9ERecycle
+r
 View%E5%8A%A0%E8%BD%BD%E7%9A%84%E5%B8%83%E5%B1%80Id%E6%95%B0
@@ -911,24 +911,141 @@
  %7D%0A%0A    /**%0A
+     * butt joint the onBindViewHolder and%0A     * If you want to write logic in onBindViewHolder, you can write here%0A
      * %E5%AF%B9%E6%8E%A5%E4%BA%86on
@@ -2020,24 +2020,116 @@
  %7D%0A%0A    /**%0A
+     * Please write judgment logic when more layout%0A     * and not write when single layout%0A
      * %E5%A6%82%E6%9E%9C%E6%98%AF%E5%A4%9A%E5%B8%83

modify test adapter