Some fixes.
parent
8ba6f1b177
commit
ff193fab23
|
@ -110,8 +110,11 @@ public class WikiUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
WikiResponse wikiResponse = new WikiResponse();
|
WikiResponse wikiResponse = new WikiResponse();
|
||||||
wikiResponse.setBatchComplete(Boolean.valueOf(object.getString("batchcomplete")));
|
wikiResponse.setBatchComplete(Boolean.valueOf(object.optString("batchcomplete")));
|
||||||
wikiResponse.setPages(fetchPages(object.getJSONObject("query").getJSONObject("pages")));
|
final JSONObject query = object.optJSONObject("query");
|
||||||
|
if (query != null) {
|
||||||
|
wikiResponse.setPages(fetchPages(query.optJSONObject("pages")));
|
||||||
|
}
|
||||||
return wikiResponse;
|
return wikiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +123,7 @@ public class WikiUtils {
|
||||||
Iterator<String> pagesIds = jpages.keys();
|
Iterator<String> pagesIds = jpages.keys();
|
||||||
while (pagesIds.hasNext()) {
|
while (pagesIds.hasNext()) {
|
||||||
String pageId = pagesIds.next();
|
String pageId = pagesIds.next();
|
||||||
pages.add(fetchPage(jpages.getJSONObject(pageId)));
|
pages.add(fetchPage(jpages.optJSONObject(pageId)));
|
||||||
}
|
}
|
||||||
return pages;
|
return pages;
|
||||||
}
|
}
|
||||||
|
@ -141,9 +144,9 @@ public class WikiUtils {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
WikiThumbnail wikiThumbnail = new WikiThumbnail();
|
WikiThumbnail wikiThumbnail = new WikiThumbnail();
|
||||||
wikiThumbnail.setWidth(jthumbnail.getLong("width"));
|
wikiThumbnail.setWidth(jthumbnail.optLong("width"));
|
||||||
wikiThumbnail.setHeight(jthumbnail.getLong("height"));
|
wikiThumbnail.setHeight(jthumbnail.optLong("height"));
|
||||||
wikiThumbnail.setSource(jthumbnail.getString("source"));
|
wikiThumbnail.setSource(jthumbnail.optString("source"));
|
||||||
return wikiThumbnail;
|
return wikiThumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +159,7 @@ public class WikiUtils {
|
||||||
|
|
||||||
int n = jcoordinates.length();
|
int n = jcoordinates.length();
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
wikiLocations.add(fetchCoordinate(jcoordinates.getJSONObject(i)));
|
wikiLocations.add(fetchCoordinate(jcoordinates.optJSONObject(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return wikiLocations;
|
return wikiLocations;
|
||||||
|
@ -164,10 +167,10 @@ public class WikiUtils {
|
||||||
|
|
||||||
public static WikiLocation fetchCoordinate(JSONObject jlocation) throws JSONException {
|
public static WikiLocation fetchCoordinate(JSONObject jlocation) throws JSONException {
|
||||||
WikiLocation wikiLocation = new WikiLocation();
|
WikiLocation wikiLocation = new WikiLocation();
|
||||||
wikiLocation.setLatitude(jlocation.getDouble("lat"));
|
wikiLocation.setLatitude(jlocation.optDouble("lat"));
|
||||||
wikiLocation.setLongitude(jlocation.getDouble("lon"));
|
wikiLocation.setLongitude(jlocation.optDouble("lon"));
|
||||||
wikiLocation.setPrimary(jlocation.getString("primary"));
|
wikiLocation.setPrimary(jlocation.optString("primary"));
|
||||||
wikiLocation.setGlobe(jlocation.getString("globe"));
|
wikiLocation.setGlobe(jlocation.optString("globe"));
|
||||||
return wikiLocation;
|
return wikiLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,6 +303,11 @@ public class WikiUtils {
|
||||||
|
|
||||||
List<WikiAppObject> results = new ArrayList<WikiAppObject>();
|
List<WikiAppObject> results = new ArrayList<WikiAppObject>();
|
||||||
List<WikiPage> pages = response.getPages();
|
List<WikiPage> pages = response.getPages();
|
||||||
|
if (pages == null) {
|
||||||
|
callback.callback(WikiStatus.SUCCESS, new ArrayList<WikiAppObject>());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (WikiPage page : pages) {
|
for (WikiPage page : pages) {
|
||||||
WikiAppObject appObject = new WikiAppObject();
|
WikiAppObject appObject = new WikiAppObject();
|
||||||
appObject.setTitle(page.getTitle());
|
appObject.setTitle(page.getTitle());
|
||||||
|
|
Loading…
Reference in New Issue