Search in sources :

Example 41 with VolleyError

use of com.android.volley.VolleyError in project easy by MehdiBenmesa.

the class StudentsListNoteAdapter method updateNotes.

public void updateNotes(Context c, String idModule) {
    StudentsListNoteAdapter.MyViewHolder child;
    final JSONArray students = new JSONArray();
    Iterator iter = myList.iterator();
    while (iter.hasNext()) {
        child = (MyViewHolder) iter.next();
        while (Float.parseFloat(child.note.getText().toString()) > 20) iter.next();
        JSONObject student = new JSONObject();
        try {
            student.put("reason", Examnote);
            student.put("value", child.note.getText().toString());
            student.put("student", child.idStudent.getText().toString());
            student.put("module", moduleid);
            students.put(student);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    CustomRequest jsonReq = new CustomRequest(Request.Method.POST, POST_NOTES, 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("students", students.toString());
            return params;
        }
    };
    App.getInstance().addToRequestQueue(jsonReq);
}
Also used : VolleyError(com.android.volley.VolleyError) HashMap(java.util.HashMap) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) CustomRequest(dz.easy.androidclient.Util.CustomRequest) Response(com.android.volley.Response) JSONObject(org.json.JSONObject) Iterator(java.util.Iterator)

Example 42 with VolleyError

use of com.android.volley.VolleyError in project easy by MehdiBenmesa.

the class AbsenceService method getAbsenceByStudentByModule.

public void getAbsenceByStudentByModule(String moduleID, final IAbsence callBack) throws JSONException {
    CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_ABSENCE_BY_STUDENT + "/" + 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);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) CustomRequestArray(dz.easy.androidclient.Util.CustomRequestArray) JSONArray(org.json.JSONArray)

Example 43 with VolleyError

use of com.android.volley.VolleyError in project easy by MehdiBenmesa.

the class AbsenceService method getSeanceByTeacher.

public void getSeanceByTeacher(final IAbsence callBack) throws JSONException {
    CustomRequest jsonReq = new CustomRequest(Request.Method.GET, GET_TIME_TABLE_TEACHER + "/" + App.getInstance().getUser().getString("_id"), null, new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject response) {
            callBack.onDataReceived(response);
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
        }
    });
    App.getInstance().addToRequestQueue(jsonReq);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) JSONObject(org.json.JSONObject) CustomRequest(dz.easy.androidclient.Util.CustomRequest)

Example 44 with VolleyError

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);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) CustomRequestArray(dz.easy.androidclient.Util.CustomRequestArray) GridLayoutManager(android.support.v7.widget.GridLayoutManager) JSONArray(org.json.JSONArray) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MaterialViewPagerHeaderDecorator(com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)

Example 45 with VolleyError

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);
}
Also used : VolleyError(com.android.volley.VolleyError) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) CustomRequest(dz.easy.androidclient.Util.CustomRequest) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

VolleyError (com.android.volley.VolleyError)181 Response (com.android.volley.Response)122 JSONObject (org.json.JSONObject)105 HashMap (java.util.HashMap)71 JSONException (org.json.JSONException)67 JsonObjectRequest (com.android.volley.toolbox.JsonObjectRequest)62 RequestQueue (com.android.volley.RequestQueue)58 User (model.User)50 JSONArray (org.json.JSONArray)35 CustomRequestArray (dz.easy.androidclient.Util.CustomRequestArray)18 Context (android.content.Context)17 Toast (android.widget.Toast)17 StringRequest (com.android.volley.toolbox.StringRequest)16 RestRequest (com.wordpress.rest.RestRequest)16 TextView (android.widget.TextView)12 CustomRequest (dz.easy.androidclient.Util.CustomRequest)12 MockHttpStack (com.android.volley.mock.MockHttpStack)9 GsonRequest (com.android.volley.toolbox.GsonRequest)9 ImageContainer (com.android.volley.toolbox.ImageLoader.ImageContainer)9 Test (org.junit.Test)9