use of com.android.volley.VolleyError in project WordPress-Android by wordpress-mobile.
the class WPImageGetter method getDrawable.
@Override
public Drawable getDrawable(String source) {
if (mImageLoader == null || mLoadingDrawable == null || mFailedDrawable == null) {
throw new RuntimeException("Developer, you need to call setImageLoader, setLoadingDrawable and setFailedDrawable");
}
if (TextUtils.isEmpty(source)) {
return null;
}
// images in reader comments may skip "http:" (no idea why) so make sure to add protocol here
if (source.startsWith("//")) {
source = "http:" + source;
}
// and then resized)
if (mMaxSize > 0) {
source = PhotonUtils.getPhotonImageUrl(source, mMaxSize, 0);
}
final RemoteDrawable remote = new RemoteDrawable(mLoadingDrawable, mFailedDrawable);
mImageLoader.get(source, new ImageLoader.ImageListener() {
@Override
public void onErrorResponse(VolleyError error) {
remote.displayFailed();
TextView view = getView();
if (view != null) {
view.invalidate();
}
}
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
if (response.getBitmap() == null) {
AppLog.w(T.UTILS, "WPImageGetter null bitmap");
}
TextView view = getView();
if (view == null) {
AppLog.w(T.UTILS, "WPImageGetter view is invalid");
return;
}
int maxWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
if (mMaxSize > 0 && (maxWidth > mMaxSize || maxWidth == 0)) {
maxWidth = mMaxSize;
}
Drawable drawable = new BitmapDrawable(view.getContext().getResources(), response.getBitmap());
remote.setRemoteDrawable(drawable, maxWidth);
// accommodate the image isn't necessary
if (!isImmediate) {
view.setText(view.getText());
}
}
});
return remote;
}
use of com.android.volley.VolleyError in project easy by MehdiBenmesa.
the class RendezVousFragment method getRendeVousByManager.
private void getRendeVousByManager() {
CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_RDV_BY_TEACHER, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
if (GRID_LAYOUT) {
recyclerViewRendeVous.setLayoutManager(new GridLayoutManager(getActivity(), 2));
} else {
recyclerViewRendeVous.setLayoutManager(new LinearLayoutManager(getActivity()));
}
recyclerViewRendeVous.setHasFixedSize(true);
//Use this now
recyclerViewRendeVous.addItemDecoration(new MaterialViewPagerHeaderDecorator());
//recyclerViewRendeVous.setAdapter(new TeachersAdapter(response,(TeachersAdapter.AdapterInterface) RendezVousActivity.this));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
App.getInstance().addToRequestQueue(jsonReq);
}
use of com.android.volley.VolleyError in project easy by MehdiBenmesa.
the class RendezVousFragment method accept.
public void accept(JSONObject rdv, final String date, final String heur, final String remarque) {
CustomRequest jsonReq = null;
try {
jsonReq = new CustomRequest(Request.Method.POST, ACCEPT_RDV + "/" + rdv.getString("_id"), null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//hidepDialog();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("date", date);
params.put("heur", heur);
params.put("remarque", remarque);
return params;
}
};
} catch (JSONException e) {
e.printStackTrace();
}
App.getInstance().addToRequestQueue(jsonReq);
}
use of com.android.volley.VolleyError in project easy by MehdiBenmesa.
the class RendezVousService method getRendezVousByTeacher.
private void getRendezVousByTeacher(String rdvState, final IRendezVous callBack) throws JSONException {
CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_RDV_BY_TEACHER + "/" + rdvState + "/" + App.getInstance().getUser().getString("_id"), null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
callBack.onDataRecieved(response);
// recyclerViewRendeVous.setAdapter(new TestRecyclerViewAdapter(response));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
App.getInstance().addToRequestQueue(jsonReq);
}
use of com.android.volley.VolleyError in project easy by MehdiBenmesa.
the class RendezVousService method getRendeVousByStudent.
private void getRendeVousByStudent(String rdvState, final IRendezVous callBack) throws JSONException {
CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_RDV_BY_STUDENT + "/" + rdvState + "/" + App.getInstance().getUser().getString("_id"), null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
callBack.onDataRecieved(response);
// recyclerViewRendeVous.setAdapter(new TestRecyclerViewAdapter(response));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
App.getInstance().addToRequestQueue(jsonReq);
}
Aggregations