use of com.alexvasilkov.gestures.sample.adapters.PhotoListAdapter in project GestureViews by alexvasilkov.
the class Ex6AdvancedDemoActivity method initGrid.
private void initGrid() {
// Setting up images grid
final int cols = getResources().getInteger(R.integer.images_grid_columns);
views.grid.setLayoutManager(new GridLayoutManager(this, cols));
views.grid.setItemAnimator(new DefaultItemAnimator());
gridAdapter = new PhotoListAdapter(this);
gridAdapter.setLoadingOffset(PAGE_SIZE / 2);
gridAdapter.setCallbacks(new EndlessRecyclerAdapter.LoaderCallbacks() {
@Override
public boolean canLoadNextItems() {
return gridAdapter.canLoadNext();
}
@Override
public void loadNextItems() {
// We should either load all items that were loaded before state save / restore,
// or next page if we already loaded all previously shown items
int count = Math.max(savedPhotoCount, gridAdapter.getCount() + PAGE_SIZE);
Events.create(FlickrApi.LOAD_IMAGES_EVENT).param(count).post();
}
});
views.grid.setAdapter(gridAdapter);
}
Aggregations