use of com.simplecity.amp_library.ui.views.SuggestedDividerDecoration in project Shuttle by timusus.
the class SuggestedFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (recyclerView == null) {
recyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_suggested, container, false);
recyclerView.addItemDecoration(new SuggestedDividerDecoration(getResources()));
recyclerView.setRecyclerListener(new RecyclerListener());
int spanCount = ShuttleUtils.isTablet() ? 12 : 6;
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), spanCount);
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (!adapter.items.isEmpty() && position >= 0) {
ViewModel item = adapter.items.get(position);
if (item instanceof HorizontalRecyclerView || item instanceof SuggestedHeaderView || (item instanceof AlbumView && item.getViewType() == ViewType.ALBUM_LIST) || (item instanceof AlbumView && item.getViewType() == ViewType.ALBUM_LIST_SMALL) || item instanceof EmptyView) {
return spanCount;
}
if (item instanceof AlbumView && item.getViewType() == ViewType.ALBUM_CARD_LARGE) {
return 3;
}
}
return 2;
}
});
recyclerView.setLayoutManager(gridLayoutManager);
}
if (recyclerView.getAdapter() != adapter) {
recyclerView.setAdapter(adapter);
}
return recyclerView;
}
Aggregations