diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/wiki/app/WikiAppObject.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/wiki/app/WikiAppObject.java new file mode 100644 index 0000000..8ddffcf --- /dev/null +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/wiki/app/WikiAppObject.java @@ -0,0 +1,75 @@ +package pl.tpolgrabia.urbanexplorer.dto.wiki.app; + +import java.io.Serializable; + +/** + * Created by tpolgrabia on 05.09.16. + */ +public class WikiAppObject implements Serializable { + private String url; + private String thumbnail; + private String title; + private String latitude; + private String longitude; + private String distance; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getThumbnail() { + return thumbnail; + } + + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getDistance() { + return distance; + } + + public void setDistance(String distance) { + this.distance = distance; + } + + @Override + public String toString() { + return "WikiAppObject{" + + "url='" + url + '\'' + + ", thumbnail='" + thumbnail + '\'' + + ", title='" + title + '\'' + + ", latitude='" + latitude + '\'' + + ", longitude='" + longitude + '\'' + + ", distance='" + distance + '\'' + + '}'; + } +} diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/WikiUtils.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/WikiUtils.java index 95a0026..e5aeeb8 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/WikiUtils.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/WikiUtils.java @@ -211,4 +211,55 @@ public class WikiUtils { object.setPrimary(geoPage.optString("primary")); return object; } + + public static void fetchAppData(final Context ctx, + final Double latitude, + final Double longitude, + final Double radius, + final Long limit) { + + fetchGeoSearchWikiMetadata(ctx, latitude, longitude, radius, limit, new WikiGeoResponseCallback() { + @Override + public void callback(WikiStatus status, WikiGeoResponse response) { + List geoData = response.getQuery(); + if (geoData == null) { + return; + } + + List pageIds = new ArrayList(); + for (WikiGeoObject wikiGeoObject : geoData) { + pageIds.add(wikiGeoObject.getPageId()); + } + + fetchPageInfos(ctx, + pageIds, + new WikiResponseCallback() { + @Override + public void callback(WikiStatus status, WikiResponse response) { + + } + }); + } + }); + + } + + public static void fetchPageInfos(Context ctx, List pageIds, final WikiResponseCallback callback) { + AQuery aq = new AQuery(ctx); + aq.ajax("FILL_URL_TO_FIND_DATA_BY_PAGEIDS", JSONObject.class, new AjaxCallback() { + @Override + public void callback(String url, JSONObject object, AjaxStatus status) { + if (status.getCode() != 200) { + try { + callback.callback(WikiStatus.SUCCESS, fetchWikiResponse(object)); + } catch (Throwable t) { + Log.e(CLASS_TAG, "General error", t); + callback.callback(WikiStatus.GENERAL_ERROR, null); + } + } else { + callback.callback(WikiStatus.NETWORK_ERROR, null); + } + } + }); + } }