Fetching wik app dtos.

master
Tomasz Półgrabia 2016-09-06 22:57:40 +02:00
parent 8016cbf8fd
commit fee0c745b6
2 changed files with 126 additions and 0 deletions

View File

@ -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 + '\'' +
'}';
}
}

View File

@ -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<WikiGeoObject> geoData = response.getQuery();
if (geoData == null) {
return;
}
List<Long> pageIds = new ArrayList<Long>();
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<Long> pageIds, final WikiResponseCallback callback) {
AQuery aq = new AQuery(ctx);
aq.ajax("FILL_URL_TO_FIND_DATA_BY_PAGEIDS", JSONObject.class, new AjaxCallback<JSONObject>() {
@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);
}
}
});
}
}