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 b4987ec..bff6aa8 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java @@ -20,13 +20,13 @@ import pl.tpolgrabia.panoramiobindings.utils.PanoramioUtils; import pl.tpolgrabia.urbanexplorer.AppConstants; import pl.tpolgrabia.urbanexplorer.MainActivity; import pl.tpolgrabia.urbanexplorer.R; -import pl.tpolgrabia.urbanexplorer.callbacks.*; import pl.tpolgrabia.panoramiobindings.dto.PanoramioImageInfo; import pl.tpolgrabia.urbanexplorer.callbacks.geocoder.GeocodedLocationCallback; import pl.tpolgrabia.urbanexplorer.callbacks.panoramio.FetchAdditionalPanoramioPhotosCallback; -import pl.tpolgrabia.urbanexplorer.callbacks.panoramio.FetchPanoramioPhotosCallback; import pl.tpolgrabia.urbanexplorer.callbacks.panoramio.PanoramioLocationCallback; import pl.tpolgrabia.urbanexplorer.callbacks.panoramio.PanoramioProviderCallback; +import pl.tpolgrabia.urbanexplorer.dto.PanoramioRequest; +import pl.tpolgrabia.urbanexplorer.worker.PanoramioWorker; import pl.tpolgrabia.urbanexplorerutils.events.DataLoadingFinishEvent; import pl.tpolgrabia.urbanexplorerutils.events.RefreshEvent; import pl.tpolgrabia.urbanexplorer.handlers.PanoramioItemLongClickHandler; @@ -259,16 +259,26 @@ public class HomeFragment extends Fragment { Toast.makeText(getActivity(), "Location is still not available", Toast.LENGTH_SHORT).show(); return; } - PanoramioUtils.fetchPanoramioImages( - activity, - location.getLatitude(), - location.getLongitude(), - SettingsUtils.fetchRadiusX(getActivity()), - SettingsUtils.fetchRadiusY(getActivity()), - 0L, - fetchLocationPageSize(), - new FetchPanoramioPhotosCallback(this, activity) - ); + + PanoramioRequest req = new PanoramioRequest(); + req.setLatitude(location.getLatitude()); + req.setLongitude(location.getLongitude()); + req.setOffset(0L); + req.setCount(fetchLocationPageSize()); + req.setRadiusX(SettingsUtils.fetchRadiusX(getActivity())); + req.setRadiusY(SettingsUtils.fetchRadiusY(getActivity())); + new PanoramioWorker(this).execute(req); + +// PanoramioUtils.fetchPanoramioImages( +// activity, +// location.getLatitude(), +// location.getLongitude(), +// SettingsUtils.fetchRadiusX(getActivity()), +// SettingsUtils.fetchRadiusY(getActivity()), +// 0L, +// fetchLocationPageSize(), +// new FetchPanoramioPhotosCallback(this, activity) +// ); } public Semaphore getLoading() { diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/worker/PanoramioWorker.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/worker/PanoramioWorker.java index aa270b0..a812fc5 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/worker/PanoramioWorker.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/worker/PanoramioWorker.java @@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory; import pl.tpolgrabia.panoramiobindings.dto.PanoramioResponse; import pl.tpolgrabia.panoramiobindings.utils.PanoramioUtils; import pl.tpolgrabia.urbanexplorer.dto.PanoramioRequest; +import pl.tpolgrabia.urbanexplorer.fragments.HomeFragment; import retrofit2.Response; import java.io.IOException; @@ -19,6 +20,11 @@ import java.util.List; public class PanoramioWorker extends AsyncTask> { private static final Logger lg = LoggerFactory.getLogger(PanoramioWorker.class); + private final HomeFragment homeFragment; + + public PanoramioWorker(HomeFragment homeFragment) { + this.homeFragment = homeFragment; + } @Override protected List doInBackground(PanoramioRequest... params) { @@ -57,5 +63,7 @@ public class PanoramioWorker extends AsyncTask