void validateAndPerformWikiSearch(String URL, String queryParams, String wikiSearch) { String searchCriteria = queryParams; if (!searchCriteria.equalsIgnoreCase("") || searchCriteria == null) { // do nothing if (!URL.equalsIgnoreCase("") || URL == null) { // do nothing if (!wikiSearch.equalsIgnoreCase("") || wikiSearch == null) { // do nothing final GsonGetRequest<WikipediaObject> gsonGetRequest = WikipediaRequests.getWikipediaObject( new Response.Listener<WikipediaObject>() { @Override public void onResponse(WikipediaObject wikipediaObject) { // Deal with the WikipediaObject here String results = setWikiData(wikipediaObject); try { callback.returnResults(results); } catch (RemoteException e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse( wikipediaObject.getTitle(), wikipediaObject.getBody())); } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // Deal with the error here try { callback.returnResults("Network or transmission error has occurred."); } catch (RemoteException e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse( "Network or transmission error has occurred.", "Empty")); } catch (Exception e) { e.printStackTrace(); } } }, URL, searchCriteria, wikiSearch); App.addRequest(gsonGetRequest, TAG); } } } else { wikiResponse = FAILED; } }
void validateAndPerformGoogleRoute(String routeStart, String routeEnd) { String URL = "http://www.mapquestapi.com/directions/v2/"; String query = "route?key=YOUR_KEY_HERE&"; String dest = "from=" + routeEnd; String orgin = "&to=" + routeStart + "&callback=renderNarrative"; final GsonGetRequest<RouteObject> gsonGetRequest = RouteRequests.getRouteObject( new Response.Listener<RouteObject>() { @Override public void onResponse(RouteObject routeObject) { // Deal with the RouteObject here String results = setRouteData(routeObject); try { callback.returnResults(results); } catch (Exception e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse( routeObject.getTitle(), stepNumber, stepDirections, startPoint, endPoint, distance, duration)); } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { try { callback.returnResults("Network or transmission error has occurred."); } catch (Exception e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse("Network or transmission error has occurred.", "Empty")); } catch (Exception e) { e.printStackTrace(); } } }, orgin, dest, URL, query); App.addRequest(gsonGetRequest, TAG); }
void validateAndPerformOsmRoute(String routeStart, String routeEnd) { String URL = "http://router.project-osrm.org/viaroute?"; String query = ""; String dest = routeEnd; String orgin = routeStart; final GsonGetRequest<RouteObject> gsonGetRequest = RouteRequests.getOsmRoute( new Response.Listener<RouteObject>() { @Override public void onResponse(RouteObject routeObject) { // Deal with the RouteObject here String results = setRouteData(routeObject); try { callback.returnResults(results); } catch (Exception e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse( routeObject.getTitle(), stepNumber, stepDirections, startPoint, endPoint, distance, duration)); } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { try { callback.returnResults("Network or transmission error has occurred."); } catch (Exception e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse("Network or transmission error has occurred.", "Empty")); } catch (Exception e) { e.printStackTrace(); } } }, orgin, dest, URL, query); App.addRequest(gsonGetRequest, TAG); }
void validateAndPerformGeocode(String URL, String queryParams, String geocode) { String result = "No results"; String searchCriteria = null; searchCriteria = queryParams; if (searchCriteria == null || URL == null || geocode == null) { // do nothing } else { final GsonGetRequest<GeocodeObject> gsonGetRequest = GeocodeRequests.getGeocodeObject( new Response.Listener<GeocodeObject>() { @Override public void onResponse(GeocodeObject geocodeObject) { // Deal with the WikipediaObject here String results = setGeocodeData(geocodeObject); try { callback.returnResults(results); } catch (RemoteException e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse(geocodeObject.getTitle(), geocodeObject.getBody())); } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { try { callback.returnResults("Network or transmission error has occurred."); } catch (RemoteException e) { e.printStackTrace(); } try { callback.restResponse( new RestResponse("Network or transmission error has occurred.", "Empty")); } catch (Exception e) { e.printStackTrace(); } } }, searchCriteria, URL, geocode); App.addRequest(gsonGetRequest, TAG); } }