Xrecycleview多条目

#契约类

public interface HomeContract {
    public abstract class IHomePersenter{
        public abstract void getHome(HashMap map);

    }
    interface IHomeModel{
        void getHome(HashMap map, RequestCallback requestCallback);

    }
    interface IHomeView{
        
        void onFailpro(String msg);
        void onSuccesspro(HomeBean.DataBean list);

    }
}

#适配器

public class HomeAdapter extends XRecyclerView.Adapter {
    private final int TYPE_BANNER = 0;
    private final int TYPE_FENLIE = 1;
    private final int TYPE_MIAOSHA = 2;
    private final int TYPE_TUIJIAN = 3;
    private Context context;
    private HomeBean.DataBean list;

    public HomeAdapter(Context context, HomeBean.DataBean list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public XRecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        if (getItemViewType(i)==TYPE_BANNER){
            View inflate = LayoutInflater.from(context).inflate(R.layout.xbanner_item, viewGroup, false);
            VHbanner vHbanner = new VHbanner(inflate);
            return vHbanner;
        }else if(getItemViewType(i)==TYPE_FENLIE){
            View inflate = LayoutInflater.from(context).inflate(R.layout.fenlie_layout, viewGroup, false);
            VHfenlei vHfenlei = new VHfenlei(inflate);
            return vHfenlei;
        }else if(getItemViewType(i)==TYPE_MIAOSHA){
            View inflate = LayoutInflater.from(context).inflate(R.layout.miaosha_layout, viewGroup, false);
            VHmiaosha vHmiaosha = new VHmiaosha(inflate);
            return vHmiaosha;
        }else {
            View inflate = LayoutInflater.from(context).inflate(R.layout.tuijian_layout, viewGroup, false);
            VHtuijian vHtuijian = new VHtuijian(inflate);
            return vHtuijian;
        }

    }

    @Override
    public void onBindViewHolder(@NonNull XRecyclerView.ViewHolder viewHolder, int i) {

        if (list.banner!=null&&list.fenlei!=null&&list.miaosha!=null&&list.tuijian!=null){
            if (viewHolder instanceof VHbanner){
                final ArrayList b = new ArrayList<>();
                for (int j = 0;j

你可能感兴趣的:(Xrecycleview多条目)