Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
- Adapter adapter = new Adapter(cursor);
- adapter.setHasStableIds(true);
- mRecyclerView.setAdapter(adapter);
- GridLayoutManager gridLayoutManager =
- new GridLayoutManager(this, mColumnCount, GridLayoutManager.VERTICAL, false);
- mRecyclerView.setLayoutManager(gridLayoutManager);
- }
- @Override
- public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
- Adapter adapter = new Adapter(cursor);
- adapter.setHasStableIds(true);
- mRecyclerView.setAdapter(adapter);
- GridLayoutManager gridLayoutManager =
- new GridLayoutManager(this, mColumnCount, GridLayoutManager.VERTICAL, false);
- mRecyclerView.setLayoutManager(gridLayoutManager);
- // Adding the custom ItemDecoration
- EqualOffsetItemDecoration itemDecoration = new EqualOffsetItemDecoration(this, R.dimen.card_view_margin, mColumnCount);
- mRecyclerView.addItemDecoration(itemDecoration);
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- ...
- mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
- mColumnCount = getResources().getInteger(R.integer.list_column_count);
- /*
- In order to have equal spacing along the edges of the screen as well as between the
- child views of the RecyclerView, an EqualOffsetItemDecoration is applied to the RecyclerView.
- */
- EqualOffsetItemDecoration itemDecoration = new EqualOffsetItemDecoration(this, R.dimen.card_view_margin, mColumnCount);
- mRecyclerView.addItemDecoration(itemDecoration);
- ...
- }
Add Comment
Please, Sign In to add comment