Exemplo n.º 1
0
 @Override
 public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
   Adapter adapter = new Adapter(cursor);
   adapter.setHasStableIds(true);
   mRecyclerView.setAdapter(adapter);
   int columnCount = getResources().getInteger(R.integer.list_column_count);
   StaggeredGridLayoutManager sglm =
       new StaggeredGridLayoutManager(columnCount, StaggeredGridLayoutManager.VERTICAL);
   mRecyclerView.setLayoutManager(sglm);
 }
Exemplo n.º 2
0
  @Override
  public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    Adapter adapter = new Adapter(cursor);
    adapter.setHasStableIds(true);
    mRecyclerView.setAdapter(adapter);
    int columnCount =
        getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? 2 : 3;
    StaggeredGridLayoutManager staggeredGridLayoutManager =
        new StaggeredGridLayoutManager(columnCount, StaggeredGridLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(staggeredGridLayoutManager);

    SpacesItemDecoration decoration = new SpacesItemDecoration(4);
    mRecyclerView.addItemDecoration(decoration);
  }