API.Get¶
-
static class
Get¶ The protocol for GET requests is as follows… 1. Check if cache has relevant data. If so, return it. 2. Send network request to update data.
Methods¶
autocompleteLanguage¶
-
static void
autocompleteLanguage(RequestQueue queue, String text, Response.Listener<NetworkResponse<List<Language>>> listener)¶ Get potential
Languages that match a user’s query textParameters: - queue – Queue to which the asynchronous task will be added
- text – User’s query text to get autocomplete results for
- listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with theNetworkResponsecreated by the query.
autocompletePlace¶
-
static void
autocompletePlace(RequestQueue queue, String text, Response.Listener<NetworkResponse<List<Location>>> listener)¶ Get potential
Locations that match a user’s query textParameters: - queue – Queue to which the asynchronous task will be added
- text – User’s query text to get autocomplete results for
- listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with theNetworkResponsecreated by the query.
instantiatePostReplyUser¶
-
static void
instantiatePostReplyUser(RequestQueue queue, PostReply comment, Response.Listener<PostReply> listener)¶ The API will return Post JSON Objects with id’s for the user. Often, we will want to get the user information associated with a post, such as the name and profile picture. This method allows us to instantiate this user information for each post.
Parameters: - queue – The Volley RequestQueue object that handles all the request queueing.
- comment – An already instantiated PostReply object that has a null author field but a defined userId field.
- listener – the UI listener that will be called when we complete the task at hand.
instantiatePostUser¶
-
static void
instantiatePostUser(RequestQueue queue, org.codethechange.culturemesh.models.Post post, Response.Listener<org.codethechange.culturemesh.models.Post> listener)¶ The API will return Post JSON Objects with id’s for the user. Often, we will want to get the user information associated with a post, such as the name and profile picture. This method allows us to instantiate this user information for each post.
Parameters: - queue – The Volley RequestQueue object that handles all the request queueing.
- post – An already instantiated Post object that has a null author field but a defined userId field.
- listener – the UI listener that will be called when we complete the task at hand.
language¶
-
static void
language(RequestQueue queue, long id, Response.Listener<NetworkResponse<Language>> listener)¶ Get the
Languagethat has the provided IDParameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
Languageto find. Must be unique, and the same ID must be used throughout. - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with theNetworkResponsecreated by the query.
loginToken¶
Generically get a login token. If the token is fresh (less than
API.TOKEN_REFRESHseconds have passed since the last token was retrieved the current token is simply supplied. Otherwise, an attempt is made to login with the token to get a new one. If this fails, the token has expired, and the user is directed to sign in again by the error dialog. If it succeeds, the new token is stored in place of the old one.Parameters: - queue – Queue to which the asynchronous task will be added
- listener – Listener whose onResponse method will be called when task completes
See also:
NetworkResponse.genErrorDialog(Context,int,boolean,NetworkResponse.DialogTapListener),API.LOGIN_TOKEN,API.TOKEN_RETRIEVED
loginWithCred¶
Use a user’s login credentials to login to the server. A user’s credentials consist of the email address associated with their account and their password for the CultureMesh website. If the credentials are accepted by the server, the resulting LoginResponse will be stored in the
NetworkResponse, which will not be in a failed state, and passed to the listener. If the credentials are rejected, theNetworkResponsewill be in a failed state with an error message communicating the occurrence of an authentication failure and instructing the user to sign in again. After dismissing the error dialog, theLoginActivitywill be launched.Parameters: - queue – Queue to which the asynchronous task will be added
- email – Email address that will serve as the username in the attempted login
- password – Password to use in the login attempt
- listener – Will be called with the
NetworkResponsewhen the operation completes
See also:
NetworkResponse.genErrorDialog(Context,int,boolean,NetworkResponse.DialogTapListener)
loginWithToken¶
Same as
API.Get.loginWithCred(RequestQueue,String,String,SharedPreferences,Response.Listener), but a login token is used in place of the user’s credentials.Parameters: - queue – Queue to which the asynchronous task will be added
- token – Login token to use to get another token
- listener – Will be called with the
NetworkResponsewhen the operation completes
netFromFromAndNear¶
-
static void
netFromFromAndNear(RequestQueue queue, FromLocation from, NearLocation near, Response.Listener<NetworkResponse<Network>> listener)¶ Get the
Networkthat has the providedFromLocationandNearLocationParameters: - queue – Queue to which the asynchronous task will be added
- from –
FromLocationof theNetworkto find - near –
NearLocationof theNetworkto find - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with theNetworkResponsecreated by the query.
netFromLangAndNear¶
-
static void
netFromLangAndNear(RequestQueue queue, Language lang, NearLocation near, Response.Listener<NetworkResponse<Network>> listener)¶ Get the
Networkthat has the providedLanguageandNearLocationParameters: - queue – Queue to which the asynchronous task will be added
- lang –
Languageof theNetworkto find - near –
NearLocationof theNetworkto find - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with theNetworkResponsecreated by the query.
network¶
-
static void
network(RequestQueue queue, long id, Response.Listener<NetworkResponse<Network>> callback)¶ Get the
Networkcorresponding to the provided IDParameters: - queue – Queue to which the asynchronous task to get the
Networkwill be added - id – ID of the
Networkto get - callback – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with theNetworkResponsecreated by the query.
- queue – Queue to which the asynchronous task to get the
networkEvents¶
-
static void
networkEvents(RequestQueue queue, long id, String maxId, Response.Listener<NetworkResponse<List<Event>>> listener)¶ Get the
Events corresponding to aNetworkParameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
NetworkwhoseEvents will be fetched - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with theNetworkResponsecreated by the query.
networkPostCount¶
-
static void
networkPostCount(RequestQueue queue, long id, Response.Listener<NetworkResponse<Long>> listener)¶ Get the number of
org.codethechange.culturemesh.models.Posts that are currently on aNetworkParameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
Networkwhoseorg.codethechange.culturemesh.models.Postcount will be retrieved - listener – Listener whose
Response.Listener.onResponse(Object)is called with aNetworkResponsethat stores the result of the network request
networkPosts¶
-
static void
networkPosts(RequestQueue queue, long id, String maxId, Response.Listener<NetworkResponse<List<org.codethechange.culturemesh.models.Post>>> listener)¶ Get the
org.codethechange.culturemesh.models.Posts of aNetworkParameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
Networkwhoseorg.codethechange.culturemesh.models.Posts will be returned - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with theNetworkResponsecreated by the query.
networkUserCount¶
-
static void
networkUserCount(RequestQueue queue, long id, Response.Listener<NetworkResponse<Long>> listener)¶ Get the number of
Users who are currently members of aNetworkParameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
NetworkwhoseUsercount will be retrieved - listener – Listener whose
Response.Listener.onResponse(Object)is called with aNetworkResponsethat stores the result of the network request
networkUsers¶
-
static void
networkUsers(RequestQueue queue, long id, Response.Listener<NetworkResponse<ArrayList<User>>> listener)¶ Get all the
Users who are members of aNetworkParameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
Networkwhose users will be fetched - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with theNetworkResponsecreated by the query.
post¶
-
static void
post(RequestQueue queue, long id, Response.Listener<NetworkResponse<org.codethechange.culturemesh.models.Post>> callback)¶ Get a
org.codethechange.culturemesh.models.Postfrom it’s IDParameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
org.codethechange.culturemesh.models.Postto retrieve - callback – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with theNetworkResponsecreated by the query.
postReplies¶
-
static void
postReplies(RequestQueue queue, long id, Response.Listener<NetworkResponse<ArrayList<PostReply>>> listener)¶ Fetch the comments of a post.
Parameters: - queue – The
RequestQueueto house the network requests. - id – the id of the post that we want comments for.
- listener – the listener that we will call when the request is finished.
- queue – The
topTen¶
-
static void
topTen(RequestQueue queue, Response.Listener<NetworkResponse<ArrayList<Network>>> listener)¶ Fetches the ten
Networks with the most subscribers.Parameters: - queue – Queue to which the asynchronous task will be added
- listener – Will be called with the
NetworkResponsewhen the operation completes
user¶
-
static void
user(RequestQueue queue, long id, Response.Listener<NetworkResponse<User>> listener)¶ Get a
Userobject from it’s IDParameters: - id – ID of user to find
Returns: If such a user was found, it will be the payload. Otherwise, the request will be marked as failed.
userEvents¶
-
static void
userEvents(RequestQueue queue, long id, String role, Response.Listener<NetworkResponse<ArrayList<org.codethechange.culturemesh.models.Event>>> listener)¶ Get the
Events aUseris subscribed to.Parameters: - queue – Queue to which the asynchronous task is added.
- id – ID of the
Userwhose events are being searched for - role – Either
hostingorattending - listener – Listener whose
onResponsemethod is called with the results of the task
userEventsForNetwork¶
Get the
Events aUseris subscribed to for a givenNetwork.Parameters: - queue – Queue to which the asynchronous task is added.
- settings – SharedPreferences instance storing the token.
- networkId – the id of the
Networkof interest. - listener – The response listener to be called when the request completes.
userID¶
-
static void
userID(RequestQueue queue, String email, Response.Listener<NetworkResponse<Long>> listener)¶ Get the ID of a
Userfrom an email address. Errors are communicated via a failedNetworkResponse.Parameters: - queue – Queue to which the asynchronous task will be added
- email – Email of user whose ID to look up
- listener – Listener whose onResponse method is called when the task has completed
userNetworks¶
-
static void
userNetworks(RequestQueue queue, long id, Response.Listener<NetworkResponse<ArrayList<Network>>> listener)¶ Get the networks a user belongs to
Parameters: - queue – RequestQueue to which the asynchronous job will be added
- id – ID of the user whose networks will be fetched
- listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)is called with aNetworkResponseof anArrayListofNetworks
userPosts¶
-
static void
userPosts(RequestQueue queue, long id, Response.Listener<NetworkResponse<ArrayList<org.codethechange.culturemesh.models.Post>>> listener)¶ Get the
org.codethechange.culturemesh.models.Posts aUserhas made.Parameters: - queue – The
RequestQueuethat will house the network requests. - id – The id of the
User. - listener – The listener that the UI will call when the request is finished.
- queue – The