Implementation of autoloading next results from panoramio.

master
Tomasz Półgrabia 2016-09-01 22:58:37 +02:00
parent 8922874309
commit c9473311a4
1 changed files with 27 additions and 0 deletions
app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments

View File

@ -127,7 +127,34 @@ public class HomeFragment extends Fragment implements LocationListener {
if (firstVisibleItem + visibleItemCount >= totalItemCount) {
// scrolled to the bottom
Location location = locationService.getLastKnownLocation(locationProvider);
PanoramioUtils.fetchPanoramioImages(
getActivity(),
location.getLatitude(),
location.getLongitude(),
fetchRadiusX(),
fetchRadiusY(),
(long)(firstVisibleItem + visibleItemCount),
fetchLocationPageSize(),
new PanoramioResponseCallback() {
@Override
public void callback(PanoramioResponseStatus status, List<PanoramioImageInfo> images, Long imagesCount) {
if (status != PanoramioResponseStatus.SUCCESS) {
return;
}
PanoramioAdapter adapter = (PanoramioAdapter) locations.getAdapter();
adapter.addAll(images);
// TODO loading on end scroll should now working
// TODO we can remove pagination
// TODO we can think about removing first items also and last if the number
// TODO of items exceeds the limit (to save the memory)
}
}
);
}