use of com.android.volley.Response in project easy by MehdiBenmesa.
the class NoteService method getNoteByStudentByModule.
public void getNoteByStudentByModule(String moduleId, final INote callBack) throws JSONException {
System.out.println("AVANT ABSENCE 2 ");
CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_NOTE_BY_MODULES + "/" + App.getInstance().getUser().getString("_id") + "/" + moduleId, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
callBack.onDataReceived(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
App.getInstance().addToRequestQueue(jsonReq);
}
use of com.android.volley.Response in project easy by MehdiBenmesa.
the class AbsenceService method getAbsneceBySeance.
public void getAbsneceBySeance(String idSeance, final IAbsence callBack) {
CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_ABSENCE_BY_SEANCE + "/" + idSeance, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
callBack.onDataReceived(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
App.getInstance().addToRequestQueue(jsonReq);
}
use of com.android.volley.Response in project WordPress-Android by wordpress-mobile.
the class ReaderPostActions method bumpPageViewForPost.
public static void bumpPageViewForPost(SiteStore siteStore, ReaderPost post) {
if (post == null) {
return;
}
// don't bump stats for posts in sites the current user is an admin of, unless
// this is a private post since we count views for private posts from owner or member
SiteModel site = siteStore.getSiteBySiteId(post.blogId);
// site will be null here if the user is not the owner or a member of the site
if (site != null && !post.isPrivate) {
AppLog.d(T.READER, "skipped bump page view - user is admin");
return;
}
Response.Listener<String> listener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
AppLog.d(T.READER, "bump page view succeeded");
}
};
Response.ErrorListener errorListener = new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
AppLog.e(T.READER, volleyError);
AppLog.w(T.READER, "bump page view failed");
}
};
Request request = new StringRequest(Request.Method.GET, getTrackingPixelForPost(post), listener, errorListener) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
// call will fail without correct refer(r)er
Map<String, String> headers = new HashMap<>();
headers.put("Referer", TRACKING_REFERRER);
return headers;
}
};
WordPress.sRequestQueue.add(request);
}
use of com.android.volley.Response in project WordPress-Android by wordpress-mobile.
the class ReaderVideoUtils method requestVimeoThumbnail.
/*
* unlike YouTube thumbnails, Vimeo thumbnails require network request
*/
public static void requestVimeoThumbnail(final String videoUrl, final VideoThumbnailListener thumbListener) {
// useless without a listener
if (thumbListener == null)
return;
String id = getVimeoVideoId(videoUrl);
if (TextUtils.isEmpty(id)) {
thumbListener.onResponse(false, null);
return;
}
Response.Listener<JSONArray> listener = new Response.Listener<JSONArray>() {
public void onResponse(JSONArray response) {
String thumbnailUrl = null;
if (response != null && response.length() > 0) {
JSONObject json = response.optJSONObject(0);
if (json != null && json.has("thumbnail_large"))
thumbnailUrl = JSONUtils.getString(json, "thumbnail_large");
}
if (TextUtils.isEmpty(thumbnailUrl)) {
thumbListener.onResponse(false, null);
} else {
thumbListener.onResponse(true, thumbnailUrl);
}
}
};
Response.ErrorListener errorListener = new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
AppLog.e(T.READER, volleyError);
thumbListener.onResponse(false, null);
}
};
String url = "https://vimeo.com/api/v2/video/" + id + ".json";
JsonArrayRequest request = new JsonArrayRequest(url, listener, errorListener);
WordPress.sRequestQueue.add(request);
}
use of com.android.volley.Response in project WordPress-Android by wordpress-mobile.
the class ReaderBlogActions method checkUrlReachable.
/*
* tests whether the passed url can be reached - does NOT use authentication, and does not
* account for 404 replacement pages used by ISPs such as Charter
*/
public static void checkUrlReachable(final String blogUrl, final ReaderActions.OnRequestListener requestListener) {
// listener is required
if (requestListener == null)
return;
Response.Listener<String> listener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
requestListener.onSuccess();
}
};
Response.ErrorListener errorListener = new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
AppLog.e(T.READER, volleyError);
int statusCode;
// since a redirect to an unauthorized url may return a 301 rather than a 401
if (volleyError instanceof com.android.volley.AuthFailureError) {
statusCode = 401;
} else {
statusCode = VolleyUtils.statusCodeFromVolleyError(volleyError);
}
// success since it means the blog url is reachable
if (statusCode == 301) {
requestListener.onSuccess();
} else {
requestListener.onFailure(statusCode);
}
}
};
// TODO: this should be a HEAD request, but even though Volley supposedly supports HEAD
// using it results in "java.lang.IllegalStateException: Unknown method type"
StringRequest request = new StringRequest(Request.Method.GET, blogUrl, listener, errorListener);
WordPress.sRequestQueue.add(request);
}
Aggregations