Generated java mapping files from wiki response api.

master
Tomasz Półgrabia 2016-08-28 23:03:51 +02:00
parent 2a91ea55a7
commit 8f5256ad2c
7 changed files with 171 additions and 9 deletions

View File

@ -1,8 +0,0 @@
package pl.tpolgrabia.urbanexplorer.callbacks;
/**
* Created by tpolgrabia on 28.08.16.
*/
public class WikiResponse {
}

View File

@ -1,5 +1,7 @@
package pl.tpolgrabia.urbanexplorer.callbacks;
import pl.tpolgrabia.urbanexplorer.dto.WikiResponse;
/**
* Created by tpolgrabia on 28.08.16.
*/

View File

@ -0,0 +1,60 @@
package pl.tpolgrabia.urbanexplorer.dto;
import java.io.Serializable;
/**
* Created by tpolgrabia on 28.08.16.
*/
public class WikiLocation implements Serializable{
private static final long serialVersionUID = 2574692501816893919L;
private String globe;
private Double latitude;
private Double longitude;
private String primary;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getGlobe() {
return globe;
}
public void setGlobe(String globe) {
this.globe = globe;
}
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
public String getPrimary() {
return primary;
}
public void setPrimary(String primary) {
this.primary = primary;
}
@Override
public String toString() {
return "WikiLocation{" +
"globe='" + globe + '\'' +
", latitude=" + latitude +
", longitude=" + longitude +
", primary='" + primary + '\'' +
'}';
}
}

View File

@ -0,0 +1,13 @@
package pl.tpolgrabia.urbanexplorer.dto;
/**
* Created by tpolgrabia on 28.08.16.
*/
public class WikiPage {
private List<WikiLocation> coordinates;
private Long index;
private Long ns;
private Long pageId;
private WikiThumbnail thumbnail;
private String title;
}

View File

@ -0,0 +1,37 @@
package pl.tpolgrabia.urbanexplorer.dto;
import java.io.Serializable;
import java.util.List;
/**
* Created by tpolgrabia on 28.08.16.
*/
public class WikiResponse implements Serializable {
private static final long serialVersionUID = 2208673089408151268L;
private Boolean batchComplete;
private List<WikiPage> pages;
public Boolean getBatchComplete() {
return batchComplete;
}
public void setBatchComplete(Boolean batchComplete) {
this.batchComplete = batchComplete;
}
public List<WikiPage> getPages() {
return pages;
}
public void setPages(List<WikiPage> pages) {
this.pages = pages;
}
@Override
public String toString() {
return "WikiResponse{" +
"batchComplete=" + batchComplete +
", pages=" + pages +
'}';
}
}

View File

@ -0,0 +1,43 @@
package pl.tpolgrabia.urbanexplorer.dto;
/**
* Created by tpolgrabia on 28.08.16.
*/
public class WikiThumbnail {
private Long height;
private String source;
private Long width;
public Long getHeight() {
return height;
}
public void setHeight(Long height) {
this.height = height;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public Long getWidth() {
return width;
}
public void setWidth(Long width) {
this.width = width;
}
@Override
public String toString() {
return "WikiThumbnail{" +
"height=" + height +
", source='" + source + '\'' +
", width=" + width +
'}';
}
}

View File

@ -12,12 +12,27 @@ import pl.tpolgrabia.urbanexplorer.callbacks.WikiResponseCallback;
* Created by tpolgrabia on 28.08.16.
*/
public class WikiUtils {
public static void fetchNearPlaces(Context ctx, double latitude, double longitude, final WikiResponseCallback callback) {
private static final String WIKI_FORMAT = "json";
public static void fetchNearPlaces(Context ctx, final double latitude, final double longitude, final WikiResponseCallback callback) {
AQuery aq = new AQuery(ctx);
aq.ajax("TODO", JSONObject.class, new AjaxCallback<JSONObject>(){
@Override
public void callback(String url, JSONObject object, AjaxStatus status) {
// TODO handle response
String qurl = "https://en.wikipedia.org/w/api.php?" +
"action=query" +
"&prop=coordinates%7Cpageimages%7Cpageterms" +
"&colimit=50" +
"&piprop=thumbnail" +
"&pithumbsize=144" +
"&pilimit=50" +
"&wbptterms=description" +
"&generator=geosearch" +
"&ggscoord=" + latitude + "%7C" + longitude +
"&ggsradius=10000" +
"&ggslimit=50" +
"&format" + WIKI_FORMAT;
callback.callback(null, null);
}
});