Guest User

Untitled

a guest
Feb 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. @Override
  2. public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
  3. Adapter adapter = new Adapter(cursor);
  4. adapter.setHasStableIds(true);
  5. mRecyclerView.setAdapter(adapter);
  6.  
  7. GridLayoutManager gridLayoutManager =
  8. new GridLayoutManager(this, mColumnCount, GridLayoutManager.VERTICAL, false);
  9.  
  10. mRecyclerView.setLayoutManager(gridLayoutManager);
  11. }
  12.  
  13. @Override
  14. public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
  15. Adapter adapter = new Adapter(cursor);
  16. adapter.setHasStableIds(true);
  17. mRecyclerView.setAdapter(adapter);
  18.  
  19. GridLayoutManager gridLayoutManager =
  20. new GridLayoutManager(this, mColumnCount, GridLayoutManager.VERTICAL, false);
  21.  
  22. mRecyclerView.setLayoutManager(gridLayoutManager);
  23.  
  24. // Adding the custom ItemDecoration
  25. EqualOffsetItemDecoration itemDecoration = new EqualOffsetItemDecoration(this, R.dimen.card_view_margin, mColumnCount);
  26. mRecyclerView.addItemDecoration(itemDecoration);
  27. }
  28.  
  29. @Override
  30. protected void onCreate(Bundle savedInstanceState) {
  31. ...
  32.  
  33. mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
  34. mColumnCount = getResources().getInteger(R.integer.list_column_count);
  35.  
  36. /*
  37. In order to have equal spacing along the edges of the screen as well as between the
  38. child views of the RecyclerView, an EqualOffsetItemDecoration is applied to the RecyclerView.
  39. */
  40. EqualOffsetItemDecoration itemDecoration = new EqualOffsetItemDecoration(this, R.dimen.card_view_margin, mColumnCount);
  41. mRecyclerView.addItemDecoration(itemDecoration);
  42.  
  43. ...
  44. }
Add Comment
Please, Sign In to add comment