Search in sources :

Example 1 with CustomRequest

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

the class TimeLineActivity method setDataListItemsStudent.

public void setDataListItemsStudent(final Itimeline callback) {
    try {
        CustomRequest jsonReq = new CustomRequest(Request.Method.GET, GET_TIME_TABLE_STUDENT + "/" + user.getString("section") + "/" + user.getString("groupe"), 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 2 with CustomRequest

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

the class StartActivity method handleSignInResult.

// [END onActivityResult]
// 1D:80:89:02:65:1A:38:03:60:08:D1:38:24:EA:CA:C0:F9:59:48:AC
// [START handleSignInResult]
private void handleSignInResult(GoogleSignInResult result) {
    Log.d(TAG, "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();
        updateUI(true);
        App.getInstance().setAccessToken(acct.getIdToken());
        App.getInstance().setEmail(acct.getEmail());
        if (acct.getEmail().substring(acct.getEmail().length() - 6, acct.getEmail().length()).equals("esi.dz")) {
            CustomRequest jsonReq = new CustomRequest(Request.Method.POST, APP_LOGIN, null, new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    try {
                        JSONObject user = response.getJSONObject("user");
                        Log.i(TAG, "Signed in as: " + user.getString("name"));
                        // JSONArray resp = responseBody.to;
                        if (user.getString("mail").equals(App.getInstance().getEmail())) {
                            startUserActivity(user);
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }, 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("email", App.getInstance().getEmail());
                    params.put("idToken", App.getInstance().getAccessToken());
                    return params;
                }
            };
            App.getInstance().addToRequestQueue(jsonReq);
        } else {
            String msg = "c'est pas un compte ESI ";
            Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
        }
    } else {
        // Signed out, show unauthenticated UI.
        updateUI(false);
    }
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) JSONException(org.json.JSONException) CustomRequest(dz.easy.androidclient.Util.CustomRequest)

Example 3 with CustomRequest

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

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

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

the class RendezVousActivity method ajouterRdv.

public void ajouterRdv(final String idTeacher, final String date, final String remarque) {
    CustomRequest jsonReq = null;
    jsonReq = new CustomRequest(Request.Method.POST, POST_RDV, 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("teacher", idTeacher);
            params.put("date", date);
            params.put("reason", remarque);
            try {
                params.put("student", user.getString("_id"));
            } catch (JSONException e) {
                e.printStackTrace();
            }
            return params;
        }
    };
    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) HashMap(java.util.HashMap) Map(java.util.Map)

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