From c9473311a41f7cd0075e30b3305a4dce10edd149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20P=C3=B3=C5=82grabia?= Date: Thu, 1 Sep 2016 22:58:37 +0200 Subject: [PATCH] Implementation of autoloading next results from panoramio. --- .../urbanexplorer/fragments/HomeFragment.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java index a4f83c4..61c87b0 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java @@ -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 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) + + } + } + + ); }