public class VolleyManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
VolleyManager.VolleyResponseListener<E>
An interface to manage responses from the server
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
baseURL |
(package private) boolean |
connection |
private Context |
context |
private static VolleyManager |
instance |
private static java.util.Locale |
locale |
static java.lang.String |
OK_RESPONSE |
com.android.volley.RequestQueue |
requestQueue |
private static java.lang.String |
TAG |
private java.lang.String[] |
URL_Array |
Modifier | Constructor and Description |
---|---|
private |
VolleyManager(Context c) |
Modifier and Type | Method and Description |
---|---|
void |
deleteSquare(java.lang.String squareId,
java.lang.String ownerId,
VolleyManager.VolleyResponseListener listener)
Deletes a square and all the messages contained in it from the database
|
java.util.List<Message> |
deserializeMessages(java.lang.String jsonResponse)
Deserializes a list of messages received from the server
|
java.util.List<Square> |
deserializeSquares(java.lang.String jsonResponse)
Deserializes a list of squares received from the server
|
private java.lang.String |
emptySpacesForParams(java.lang.String urlParameter)
Removes empty spaces from strings
|
void |
getClosestSquares(java.lang.String distance,
double lat,
double lon,
VolleyManager.VolleyResponseListener listener)
Searchs on the server's database for squares around a certain position and a certain distance
|
void |
getFavoriteSquares(java.lang.String userId,
VolleyManager.VolleyResponseListener listener)
Downloads user's favourite squares
|
static VolleyManager |
getInstance() |
static VolleyManager |
getInstance(Context c) |
void |
getOwnedSquares(java.lang.String byOwner,
java.lang.String ownerId,
VolleyManager.VolleyResponseListener listener)
Downloads user's owned squares
|
void |
getRecentMessages(java.lang.String isRecentRequest,
java.lang.String howMany,
java.lang.String squareId,
VolleyManager.VolleyResponseListener listener)
Gets the most recent messages from a square
|
void |
getRecentSquares(java.lang.String userId,
VolleyManager.VolleyResponseListener listener)
Downloads user's recent squares
|
void |
handleFavoriteSquare(int requestType,
java.lang.String squareId,
java.lang.String userId,
VolleyManager.VolleyResponseListener listener)
Adds or removes a square from the user's favourite
|
void |
patchDescription(java.lang.String name,
java.lang.String description,
java.lang.String squareId,
java.lang.String ownerId,
VolleyManager.VolleyResponseListener listener)
Updates name and description of the square
|
void |
patchGCMToken(java.lang.String token,
VolleyManager.VolleyResponseListener listener)
Updates the GCM Token, if expired
|
void |
patchLocation(java.lang.String latitude,
java.lang.String longitude,
java.lang.String userId,
java.lang.String isUpdateLocation,
VolleyManager.VolleyResponseListener listener)
Updates the location of a square
|
void |
patchLoginToken(java.lang.String service,
java.lang.String accessToken,
VolleyManager.VolleyResponseListener listener)
Updates the access token for the login
|
void |
postFacebookSquare(java.lang.String squareName,
java.lang.String squareDescr,
java.lang.String latitude,
java.lang.String longitude,
java.lang.String ownerId,
java.lang.String squareType,
java.lang.String facebookId,
java.lang.String expireTime,
VolleyManager.VolleyResponseListener listener)
POST request to create a Facebook square (Page or Event)
|
void |
postFeedback(java.lang.String feedback,
java.lang.String userId,
java.lang.String fromActivity,
VolleyManager.VolleyResponseListener listener)
Sends a feedback that will be stored on the backend database
|
void |
postLoginToken(java.lang.String service,
java.lang.String accessToken,
VolleyManager.VolleyResponseListener listener)
Manages the POST request to login via Google/Facebook
|
void |
postSquare(java.lang.String squareName,
java.lang.String squareDescr,
java.lang.String latitude,
java.lang.String longitude,
java.lang.String ownerId,
VolleyManager.VolleyResponseListener listener)
POST request to create a new square
|
void |
searchSquares(java.lang.String query,
java.lang.String userId,
double lat,
double lon,
VolleyManager.VolleyResponseListener listener)
Searches for squares in the server's database
|
public static final java.lang.String OK_RESPONSE
private static final java.lang.String TAG
private static VolleyManager instance
private static java.util.Locale locale
private Context context
private java.lang.String[] URL_Array
private static java.lang.String baseURL
boolean connection
public com.android.volley.RequestQueue requestQueue
public static VolleyManager getInstance(Context c)
public static VolleyManager getInstance()
public void searchSquares(java.lang.String query, java.lang.String userId, double lat, double lon, VolleyManager.VolleyResponseListener listener)
query
- the query of the useruserId
- the id of the userlat
- the latitude of the position of the userlon
- the longitude of the position of the userlistener
- the listener to handle the resultspublic void getClosestSquares(java.lang.String distance, double lat, double lon, VolleyManager.VolleyResponseListener listener)
distance
- the radius of researchlat
- the latitude of the position of the userlon
- the longitude of the position of the userlistener
- the listener to handle the resultspublic void getRecentMessages(java.lang.String isRecentRequest, java.lang.String howMany, java.lang.String squareId, VolleyManager.VolleyResponseListener listener)
isRecentRequest
- if true gets the user the most recent messageshowMany
- the number of messages to downloadsquareId
- the square id from which to downloadlistener
- the listener to handle the resultspublic void handleFavoriteSquare(int requestType, java.lang.String squareId, java.lang.String userId, VolleyManager.VolleyResponseListener listener)
requestType
- POST for adding, DELETE for removingsquareId
- the square to add/removeuserId
- the user's idlistener
- the listener to handle the resultspublic void postLoginToken(java.lang.String service, java.lang.String accessToken, VolleyManager.VolleyResponseListener listener)
service
- the service you want to useaccessToken
- the access tokenlistener
- the listener to handle the resultspublic void patchLoginToken(java.lang.String service, java.lang.String accessToken, VolleyManager.VolleyResponseListener listener)
service
- the service you want to useaccessToken
- the access tokenlistener
- the listener to handle the resultspublic void patchGCMToken(java.lang.String token, VolleyManager.VolleyResponseListener listener)
token
- the new tokenlistener
- the listener to handle the resultspublic void postFeedback(java.lang.String feedback, java.lang.String userId, java.lang.String fromActivity, VolleyManager.VolleyResponseListener listener)
feedback
- the feedbackuserId
- the user that submitted itfromActivity
- from which activity it was submittedlistener
- the listener to handle the resultspublic void postSquare(java.lang.String squareName, java.lang.String squareDescr, java.lang.String latitude, java.lang.String longitude, java.lang.String ownerId, VolleyManager.VolleyResponseListener listener)
squareName
- name of the squaresquareDescr
- description of the squarelatitude
- latitude of the position of the squarelongitude
- longitude of the position of the squareownerId
- the id of the ownerlistener
- the listener to handle the resultspublic void postFacebookSquare(java.lang.String squareName, java.lang.String squareDescr, java.lang.String latitude, java.lang.String longitude, java.lang.String ownerId, java.lang.String squareType, java.lang.String facebookId, java.lang.String expireTime, VolleyManager.VolleyResponseListener listener)
squareName
- name of the squaresquareDescr
- description of the squarelatitude
- latitude of the position of the squarelongitude
- longitude of the position of the squareownerId
- the id of the ownersquareType
- type of the squarefacebookId
- Facebook's id of the page/eventexpireTime
- expiration time of the squarelistener
- the listener to handle the resultspublic void getOwnedSquares(java.lang.String byOwner, java.lang.String ownerId, VolleyManager.VolleyResponseListener listener)
byOwner
- true if the research is for the ownerownerId
- the id of the ownerlistener
- the listener to handle the resultspublic void getFavoriteSquares(java.lang.String userId, VolleyManager.VolleyResponseListener listener)
userId
- the id of the userlistener
- the listener to handle the resultspublic void getRecentSquares(java.lang.String userId, VolleyManager.VolleyResponseListener listener)
userId
- the id of the userlistener
- the listener to handle the resultspublic java.util.List<Square> deserializeSquares(java.lang.String jsonResponse)
jsonResponse
- the data received from the serverpublic java.util.List<Message> deserializeMessages(java.lang.String jsonResponse)
jsonResponse
- the data received from the serverpublic void patchDescription(java.lang.String name, java.lang.String description, java.lang.String squareId, java.lang.String ownerId, VolleyManager.VolleyResponseListener listener)
name
- the new namedescription
- the new descriptionsquareId
- the id of the square to updateownerId
- the id of the owner of the squarelistener
- the listener to handle the resultspublic void patchLocation(java.lang.String latitude, java.lang.String longitude, java.lang.String userId, java.lang.String isUpdateLocation, VolleyManager.VolleyResponseListener listener)
latitude
- the new latitude of the squarelongitude
- the new longitude of the squareuserId
- the id of the userisUpdateLocation
- true if the location has to be updatedlistener
- the listener to handle the resultspublic void deleteSquare(java.lang.String squareId, java.lang.String ownerId, VolleyManager.VolleyResponseListener listener)
squareId
- the id of the squareownerId
- the id of the ownerlistener
- the listener to handle the resultsprivate java.lang.String emptySpacesForParams(java.lang.String urlParameter)
urlParameter
- the url