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
Language
s 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 theNetworkResponse
created by the query.
autocompletePlace¶
-
static void
autocompletePlace
(RequestQueue queue, String text, Response.Listener<NetworkResponse<List<Location>>> listener)¶ Get potential
Location
s 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 theNetworkResponse
created 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
Language
that has the provided IDParameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
Language
to 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 theNetworkResponse
created by the query.
loginToken¶
Generically get a login token. If the token is fresh (less than
API.TOKEN_REFRESH
seconds 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)
,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, theNetworkResponse
will 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, theLoginActivity
will 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
NetworkResponse
when the operation completes
See also:
NetworkResponse.genErrorDialog(Context,int,boolean)
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
NetworkResponse
when the operation completes
netFromFromAndNear¶
-
static void
netFromFromAndNear
(RequestQueue queue, FromLocation from, NearLocation near, Response.Listener<NetworkResponse<Network>> listener)¶ Get the
Network
that has the providedFromLocation
andNearLocation
Parameters: - queue – Queue to which the asynchronous task will be added
- from –
FromLocation
of theNetwork
to find - near –
NearLocation
of theNetwork
to find - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)
is called with theNetworkResponse
created by the query.
netFromLangAndNear¶
-
static void
netFromLangAndNear
(RequestQueue queue, Language lang, NearLocation near, Response.Listener<NetworkResponse<Network>> listener)¶ Get the
Network
that has the providedLanguage
andNearLocation
Parameters: - queue – Queue to which the asynchronous task will be added
- lang –
Language
of theNetwork
to find - near –
NearLocation
of theNetwork
to find - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)
is called with theNetworkResponse
created by the query.
network¶
-
static void
network
(RequestQueue queue, long id, Response.Listener<NetworkResponse<Network>> callback)¶ Get the
Network
corresponding to the provided IDParameters: - queue – Queue to which the asynchronous task to get the
Network
will be added - id – ID of the
Network
to get - callback – Listener whose
com.android.volley.Response.Listener.onResponse(Object)
is called with theNetworkResponse
created 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
Event
s corresponding to aNetwork
Parameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
Network
whoseEvent
s will be fetched - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)
is called with theNetworkResponse
created by the query.
networkPostCount¶
-
static void
networkPostCount
(RequestQueue queue, long id, Response.Listener<NetworkResponse<Long>> listener)¶ Get the number of
org.codethechange.culturemesh.models.Post
s that are currently on aNetwork
Parameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
Network
whoseorg.codethechange.culturemesh.models.Post
count will be retrieved - listener – Listener whose
Response.Listener.onResponse(Object)
is called with aNetworkResponse
that 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.Post
s of aNetwork
Parameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
Network
whoseorg.codethechange.culturemesh.models.Post
s will be returned - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)
is called with theNetworkResponse
created by the query.
networkUserCount¶
-
static void
networkUserCount
(RequestQueue queue, long id, Response.Listener<NetworkResponse<Long>> listener)¶ Get the number of
User
s who are currently members of aNetwork
Parameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
Network
whoseUser
count will be retrieved - listener – Listener whose
Response.Listener.onResponse(Object)
is called with aNetworkResponse
that stores the result of the network request
networkUsers¶
-
static void
networkUsers
(RequestQueue queue, long id, Response.Listener<NetworkResponse<ArrayList<User>>> listener)¶ Get all the
User
s who are members of aNetwork
Parameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
Network
whose users will be fetched - listener – Listener whose
com.android.volley.Response.Listener.onResponse(Object)
is called with theNetworkResponse
created 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.Post
from it’s IDParameters: - queue – Queue to which the asynchronous task will be added
- id – ID of the
org.codethechange.culturemesh.models.Post
to retrieve - callback – Listener whose
com.android.volley.Response.Listener.onResponse(Object)
is called with theNetworkResponse
created 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
RequestQueue
to 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
user¶
-
static void
user
(RequestQueue queue, long id, Response.Listener<NetworkResponse<User>> listener)¶ Get a
User
object 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
Event
s aUser
is subscribed to.Parameters: - queue – Queue to which the asynchronous task is added.
- id – ID of the
User
whose events are being searched for - role – Either
hosting
orattending
- listener – Listener whose
onResponse
method is called with the results of the task
userEventsForNetwork¶
Get the
Event
s aUser
is 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
Network
of 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
User
from 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 aNetworkResponse
of anArrayList
ofNetwork
s
userPosts¶
-
static void
userPosts
(RequestQueue queue, long id, Response.Listener<NetworkResponse<ArrayList<org.codethechange.culturemesh.models.Post>>> listener)¶ Get the
org.codethechange.culturemesh.models.Post
s aUser
has made.Parameters: - queue – The
RequestQueue
that 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