Adding commons lang3 and fetching app results with distance.

master
Tomasz Półgrabia 2016-09-08 21:05:02 +02:00
parent fee0c745b6
commit 953e27ea2f
2 changed files with 16 additions and 8 deletions

View File

@ -27,4 +27,5 @@ dependencies {
compile 'com.android.support:recyclerview-v7:21.0.3' compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.googlecode.android-query:android-query:0.25.9' compile 'com.googlecode.android-query:android-query:0.25.9'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'org.apache.commons:commons-lang3:3.4'
} }

View File

@ -5,6 +5,7 @@ import android.util.Log;
import com.androidquery.AQuery; import com.androidquery.AQuery;
import com.androidquery.callback.AjaxCallback; import com.androidquery.callback.AjaxCallback;
import com.androidquery.callback.AjaxStatus; import com.androidquery.callback.AjaxStatus;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -216,7 +217,8 @@ public class WikiUtils {
final Double latitude, final Double latitude,
final Double longitude, final Double longitude,
final Double radius, final Double radius,
final Long limit) { final Long limit,
final WikiResponseCallback callback) {
fetchGeoSearchWikiMetadata(ctx, latitude, longitude, radius, limit, new WikiGeoResponseCallback() { fetchGeoSearchWikiMetadata(ctx, latitude, longitude, radius, limit, new WikiGeoResponseCallback() {
@Override @Override
@ -231,14 +233,11 @@ public class WikiUtils {
pageIds.add(wikiGeoObject.getPageId()); pageIds.add(wikiGeoObject.getPageId());
} }
WikiResponseCallback tcallback = callback;
fetchPageInfos(ctx, fetchPageInfos(ctx,
pageIds, pageIds,
new WikiResponseCallback() { tcallback);
@Override
public void callback(WikiStatus status, WikiResponse response) {
}
});
} }
}); });
@ -246,7 +245,15 @@ public class WikiUtils {
public static void fetchPageInfos(Context ctx, List<Long> pageIds, final WikiResponseCallback callback) { public static void fetchPageInfos(Context ctx, List<Long> pageIds, final WikiResponseCallback callback) {
AQuery aq = new AQuery(ctx); AQuery aq = new AQuery(ctx);
aq.ajax("FILL_URL_TO_FIND_DATA_BY_PAGEIDS", JSONObject.class, new AjaxCallback<JSONObject>() { aq.ajax("https://en.wikipedia.org/w/api.php" +
"?action=query" +
"&prop=coordinates%7Cpageimages%7Cpageterms" +
"&colimit=50" +
"&piprop=thumbnail" +
"&pithumbsize=144" +
"&pilimit=50" +
"&wbptterms=description" +
"&pageids=" + StringUtils.join(pageIds, "|"), JSONObject.class, new AjaxCallback<JSONObject>() {
@Override @Override
public void callback(String url, JSONObject object, AjaxStatus status) { public void callback(String url, JSONObject object, AjaxStatus status) {
if (status.getCode() != 200) { if (status.getCode() != 200) {