Search in sources :

Example 1 with ProjectsAdapter

use of com.byoutline.kickmaterial.adapters.ProjectsAdapter in project kickmaterial by byoutline.

the class ProjectsListFragment method setUpAdapters.

private void setUpAdapters() {
    /** NEW ADAPTER **/
    layoutManager = new GridLayoutManager(getActivity(), 2);
    final boolean showHeader = sharedPreferences.getBoolean(PREFS_SHOW_HEADER, true);
    // TODO: decide when to hide it.
    sharedPreferences.edit().putBoolean(PREFS_SHOW_HEADER, false).apply();
    final ProjectsAdapter.ItemViewTypeProvider itemViewTypeProvider = new ProjectsAdapter.ItemViewTypeProvider(showHeader);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            if (itemViewTypeProvider.getViewType(position) == ProjectsAdapter.NORMAL_ITEM) {
                return 1;
            }
            return 2;
        }
    });
    projectListRv.setEndlessScrollListener(this);
    projectListRv.setLayoutManager(layoutManager);
    adapter = new ProjectsAdapter(getActivity(), this, showHeader, itemViewTypeProvider);
    projectListRv.setAdapter(adapter);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) ProjectsAdapter(com.byoutline.kickmaterial.adapters.ProjectsAdapter)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 ProjectsAdapter (com.byoutline.kickmaterial.adapters.ProjectsAdapter)1