diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/callbacks/WikiResponse.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/callbacks/WikiResponse.java deleted file mode 100644 index 8137ced..0000000 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/callbacks/WikiResponse.java +++ /dev/null @@ -1,8 +0,0 @@ -package pl.tpolgrabia.urbanexplorer.callbacks; - -/** - * Created by tpolgrabia on 28.08.16. - */ -public class WikiResponse { - -} diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/callbacks/WikiResponseCallback.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/callbacks/WikiResponseCallback.java index b46ae72..7ee1b26 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/callbacks/WikiResponseCallback.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/callbacks/WikiResponseCallback.java @@ -1,5 +1,7 @@ package pl.tpolgrabia.urbanexplorer.callbacks; +import pl.tpolgrabia.urbanexplorer.dto.WikiResponse; + /** * Created by tpolgrabia on 28.08.16. */ diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiLocation.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiLocation.java new file mode 100644 index 0000000..a75fa86 --- /dev/null +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiLocation.java @@ -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 + '\'' + + '}'; + } +} diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiPage.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiPage.java new file mode 100644 index 0000000..d25cc0a --- /dev/null +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiPage.java @@ -0,0 +1,13 @@ +package pl.tpolgrabia.urbanexplorer.dto; + +/** + * Created by tpolgrabia on 28.08.16. + */ +public class WikiPage { + private List coordinates; + private Long index; + private Long ns; + private Long pageId; + private WikiThumbnail thumbnail; + private String title; +} diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiResponse.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiResponse.java new file mode 100644 index 0000000..3e5c830 --- /dev/null +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiResponse.java @@ -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 pages; + + public Boolean getBatchComplete() { + return batchComplete; + } + + public void setBatchComplete(Boolean batchComplete) { + this.batchComplete = batchComplete; + } + + public List getPages() { + return pages; + } + + public void setPages(List pages) { + this.pages = pages; + } + + @Override + public String toString() { + return "WikiResponse{" + + "batchComplete=" + batchComplete + + ", pages=" + pages + + '}'; + } +} diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiThumbnail.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiThumbnail.java new file mode 100644 index 0000000..9f45968 --- /dev/null +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/WikiThumbnail.java @@ -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 + + '}'; + } +} 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 321b684..ad8a32e 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/WikiUtils.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/WikiUtils.java @@ -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(){ @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); } });