Search in sources :

Example 6 with CustomRequest

use of dz.easy.androidclient.Util.CustomRequest 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)

Example 7 with CustomRequest

use of dz.easy.androidclient.Util.CustomRequest in project easy by MehdiBenmesa.

the class StudentsListAbsenceAdapter method updateAbsences.

public void updateAbsences(Context c) {
    StudentsListAbsenceAdapter.MyViewHolder child;
    final JSONArray students = new JSONArray();
    Iterator iter = myList.iterator();
    int i = 0;
    while (iter.hasNext()) {
        child = (StudentsListAbsenceAdapter.MyViewHolder) iter.next();
        if (child.abs.isChecked()) {
            System.out.println("ETUDIANTS CHECKED " + child.title.getText().toString());
            try {
                students.put(i, child.idStudent.getText().toString());
                i++;
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
    CustomRequest jsonReq = new CustomRequest(Request.Method.POST, POST_UPDATE_ABSENCES, null, new Response.Listener<JSONObject>() {

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

        @Override
        public void onErrorResponse(VolleyError error) {
        }
    }) {

        @Override
        protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<String, String>();
            try {
                JSONObject absence = new JSONObject();
                absence.put("students", students);
                absence.put("idabs", adapterIdAbsence);
                params.put("absence", absence.toString());
            } catch (JSONException e) {
                e.printStackTrace();
            }
            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 8 with CustomRequest

use of dz.easy.androidclient.Util.CustomRequest in project easy by MehdiBenmesa.

the class StudentsListAbsenceAdapter method ajoutAbsences.

public void ajoutAbsences(Context c, final String idSeance) {
    StudentsListAbsenceAdapter.MyViewHolder child;
    final JSONArray students = new JSONArray();
    Iterator iter = myList.iterator();
    int i = 0;
    while (iter.hasNext()) {
        child = (StudentsListAbsenceAdapter.MyViewHolder) iter.next();
        if (child.abs.isChecked()) {
            System.out.println("ETUDIANTS CHECKED " + child.title.getText().toString());
            try {
                students.put(i, child.idStudent.getText().toString());
                i++;
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
    CustomRequest jsonReq = new CustomRequest(Request.Method.POST, POST_ABSENCES, null, new Response.Listener<JSONObject>() {

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

        @Override
        public void onErrorResponse(VolleyError error) {
        }
    }) {

        @Override
        protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<String, String>();
            // try {
            JSONObject absence = new JSONObject();
            params.put("students", students.toString());
            params.put("seance", idSeance);
            params.put("date", thisdate);
            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 9 with CustomRequest

use of dz.easy.androidclient.Util.CustomRequest in project easy by MehdiBenmesa.

the class TimeLineActivity method setDataListItemsTeacher.

public void setDataListItemsTeacher(final Itimeline callback) {
    try {
        CustomRequest jsonReq = new CustomRequest(Request.Method.GET, GET_TIME_TABLE_TEACHER + "/" + user.getString("_id"), null, new Response.Listener<JSONObject>() {

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

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

Example 10 with CustomRequest

use of dz.easy.androidclient.Util.CustomRequest in project easy by MehdiBenmesa.

the class RendezVousFragment method refuse.

public void refuse(JSONObject rdv, final String remarque) {
    CustomRequest jsonReq = null;
    try {
        jsonReq = new CustomRequest(Request.Method.POST, REFUSE_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("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)12 CustomRequest (dz.easy.androidclient.Util.CustomRequest)12 JSONObject (org.json.JSONObject)12 JSONException (org.json.JSONException)10 Response (com.android.volley.Response)9 HashMap (java.util.HashMap)8 Iterator (java.util.Iterator)3 Map (java.util.Map)3 JSONArray (org.json.JSONArray)3 GoogleSignInAccount (com.google.android.gms.auth.api.signin.GoogleSignInAccount)1