package me.zsj.interessant.provider.related;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import me.drakeet.multitype.ItemViewProvider;
import me.zsj.interessant.R;
import me.zsj.interessant.model.ItemList;

/**
 * @author zsj
 */

public class CardViewProvider extends ItemViewProvider<Card, CardViewProvider.CardHolder> {

    private Activity context;

    public CardViewProvider(@NonNull Activity context) {
        this.context = context;
    }

    @NonNull @Override
    protected CardHolder onCreateViewHolder(
            @NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.item_horizontal_list, parent, false);
        return new CardHolder(view);
    }

    @Override
    protected void onBindViewHolder(@NonNull CardHolder holder, @NonNull Card card) {
        holder.setCards(card.item.data.itemList);
    }

    class CardHolder extends RecyclerView.ViewHolder {

        private RecyclerView cardList;
        private CardAdapter cardAdapter;


        public CardHolder(View itemView) {
            super(itemView);
            cardList = (RecyclerView) itemView.findViewById(R.id.card_list);
            LinearLayoutManager layoutManager = new LinearLayoutManager(itemView.getContext());
            layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
            cardList.setLayoutManager(layoutManager);
            cardAdapter = new CardAdapter(context);
            cardList.setAdapter(cardAdapter);
        }

        private void setCards(List<ItemList> items) {
            cardAdapter.setItems(items);
            cardAdapter.notifyDataSetChanged();
        }
    }


}

@@ -161,24 +161,75 @@
 outManager;%0A
+import android.support.v7.widget.LinearSnapHelper;%0A
 import andro
@@ -1307,16 +1307,86 @@
 dapter;%0A
+        private LinearSnapHelper snapHelper = new LinearSnapHelper();%0A
 %0A%0A      
@@ -1846,24 +1846,79 @@
 rdAdapter);%0A
+            snapHelper.attachToRecyclerView(cardList);%0A
         %7D%0A%0A 

Add LinearSnapHelper