Essential additional task that needs to be completed before the next step (caching).
**Current plan: **Start with 100m ggsradius and if <10 categories found, recurse with ggsradius of 10x the last one. There appears to be a limit of <=10,000m for the ggsradius (after which the API throws an error[0]) so stop at that point regardless.
[0]:
"error": {
"code": "ggsintegeroutofrange",
"info": "ggsradius may not be over 10000 (set to 10001) for users",
**2/1/16: **First draft of implementation done at https://github.com/nicolas-raoul/apps-android-commons/pull/36 , but there is an issue where categorySet hasn't actually been called yet when the categorySet.size()>=10 check to break out of the for loop is done, so it calls the API three times always. Probably needs to be handled differently.
**3/1/16: **I attempted to refactor the code according to Niedzielski's recommendations:
(1) API code needs to be refactored, ShareActivity.java should supply the Listener instead.
(2) For sending multiple API requests, RequestQueue should be refactored into a singleton pattern.
(3) The 'for' loop in my current code is running infinite loops because it isn't extracting the current request's radius. There is actually no need for a 'for' loop, we just need to check if there are enough categories and if the radius is within limits.
(4) If there are issues with static/non-static methods, refactor.
So I put the ResponseListener<T> class in ShareActivity.java, and passed it into the QueryRequest constructor. I rewrote MwVolleyApi.java (now called MwVolley.java) to try and avoid use of nested static classes where possible, as I was previously encountering issues with the methods in static classes not being able to access non-static variables or methods.
As the QueryResponse, Query, Page, and Category classes are all non static, I received the 'no arg constructor' error and fixed that by registering InstanceCreators for them as mentioned in [[ http://howtodoinjava.com/2014/06/17/google-gson-tutorial-convert-java-object-to-from-json/ | this ]] tutorial.