use of com.battlelancer.seriesguide.util.GridInsetDecoration in project SeriesGuide by UweTrottmann.
the class ShowsNowFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_now, container, false);
unbinder = ButterKnife.bind(this, v);
swipeRefreshLayout.setSwipeableChildren(R.id.scrollViewNow, R.id.recyclerViewNow);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refreshStream();
}
});
swipeRefreshLayout.setProgressViewOffset(false, getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_start_margin), getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_end_margin));
emptyView.setText(R.string.now_empty);
showError(null);
snackbarButton.setText(R.string.refresh);
snackbarButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
refreshStream();
}
});
// recycler view layout manager
final int spanCount = getResources().getInteger(R.integer.grid_column_count);
final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), spanCount);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (adapter == null) {
return 1;
}
if (position >= adapter.getItemCount()) {
return 1;
}
// make headers and more links span all columns
int type = adapter.getItem(position).type;
return (type == NowAdapter.ItemType.HEADER || type == NowAdapter.ItemType.MORE_LINK) ? spanCount : 1;
}
});
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new GridInsetDecoration(getResources()));
recyclerView.setHasFixedSize(true);
return v;
}
use of com.battlelancer.seriesguide.util.GridInsetDecoration in project SeriesGuide by UweTrottmann.
the class MoviesNowFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_now, container, false);
unbinder = ButterKnife.bind(this, v);
swipeRefreshLayout.setSwipeableChildren(R.id.scrollViewNow, R.id.recyclerViewNow);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refreshStream();
}
});
swipeRefreshLayout.setProgressViewOffset(false, getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_start_margin), getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_end_margin));
emptyView.setText(R.string.now_movies_empty);
showError(null);
snackbarButton.setText(R.string.refresh);
snackbarButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
refreshStream();
}
});
// recycler view layout manager
final int spanCount = getResources().getInteger(R.integer.grid_column_count);
final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), spanCount);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (adapter == null) {
return 1;
}
if (position >= adapter.getItemCount()) {
return 1;
}
// make headers and more links span all columns
int type = adapter.getItem(position).type;
return (type == NowAdapter.ItemType.HEADER || type == NowAdapter.ItemType.MORE_LINK) ? spanCount : 1;
}
});
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new GridInsetDecoration(getResources()));
recyclerView.setHasFixedSize(true);
return v;
}
Aggregations