Search in sources :

Example 1 with TestRecyclerViewAdapter

use of com.github.florent37.materialviewpager.sample.TestRecyclerViewAdapter in project MaterialViewPager by florent37.

the class RecyclerViewFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    final List<Object> items = new ArrayList<>();
    for (int i = 0; i < ITEM_COUNT; ++i) {
        items.add(new Object());
    }
    if (GRID_LAYOUT) {
        mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    } else {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    }
    mRecyclerView.setHasFixedSize(true);
    //Use this now
    mRecyclerView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
    mRecyclerView.setAdapter(new TestRecyclerViewAdapter(items));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TestRecyclerViewAdapter(com.github.florent37.materialviewpager.sample.TestRecyclerViewAdapter) MaterialViewPagerHeaderDecorator(com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)

Example 2 with TestRecyclerViewAdapter

use of com.github.florent37.materialviewpager.sample.TestRecyclerViewAdapter in project easy by MehdiBenmesa.

the class RecyclerViewFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    final List<Object> items = new ArrayList<>();
    for (int i = 0; i < ITEM_COUNT; ++i) {
        items.add(new Object());
    }
    if (GRID_LAYOUT) {
        mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    } else {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    }
    mRecyclerView.setHasFixedSize(true);
    //Use this now
    mRecyclerView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
    mRecyclerView.setAdapter(new TestRecyclerViewAdapter(items));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TestRecyclerViewAdapter(com.github.florent37.materialviewpager.sample.TestRecyclerViewAdapter) MaterialViewPagerHeaderDecorator(com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 MaterialViewPagerHeaderDecorator (com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)2 TestRecyclerViewAdapter (com.github.florent37.materialviewpager.sample.TestRecyclerViewAdapter)2 ArrayList (java.util.ArrayList)2