Search in sources :

Example 46 with VolleyError

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);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) CustomRequestArray(dz.easy.androidclient.Util.CustomRequestArray) JSONArray(org.json.JSONArray)

Example 47 with VolleyError

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);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) CustomRequestArray(dz.easy.androidclient.Util.CustomRequestArray) JSONArray(org.json.JSONArray)

Example 48 with VolleyError

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

the class ModuleService method getModulesByStudent.

public void getModulesByStudent(final IModule callBack) {
    try {
        CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_MODULES_BY_STUDENT + "/" + App.getInstance().getUser().getString("section") + "/" + App.getInstance().getUser().getString("groupe"), null, new Response.Listener<JSONArray>() {

            @Override
            public void onResponse(JSONArray 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) CustomRequestArray(dz.easy.androidclient.Util.CustomRequestArray) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Example 49 with VolleyError

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

the class ModuleService method getModulesByTeacher.

private void getModulesByTeacher(final IModule callBack) throws JSONException {
    //  dialogListner.showDialog();
    /* Starting Download Service */
    CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_MODULES_BY_TEACHER + "/" + App.getInstance().getUser().getString("_id"), null, new Response.Listener<JSONArray>() {

        @Override
        public void onResponse(JSONArray response) {
            callBack.onDataRecieved(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 50 with VolleyError

use of com.android.volley.VolleyError in project WordPress-Android by wordpress-mobile.

the class NotificationsUtils method registerDeviceForPushNotifications.

public static void registerDeviceForPushNotifications(final Context ctx, String token) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(ctx);
    String uuid = settings.getString(WPCOM_PUSH_DEVICE_UUID, null);
    if (uuid == null)
        return;
    String deviceName = DeviceUtils.getInstance().getDeviceName(ctx);
    Map<String, String> contentStruct = new HashMap<>();
    contentStruct.put("device_token", token);
    contentStruct.put("device_family", "android");
    contentStruct.put("device_name", deviceName);
    contentStruct.put("device_model", Build.MANUFACTURER + " " + Build.MODEL);
    contentStruct.put("app_version", WordPress.versionName);
    contentStruct.put("version_code", String.valueOf(PackageUtils.getVersionCode(ctx)));
    contentStruct.put("os_version", Build.VERSION.RELEASE);
    contentStruct.put("device_uuid", uuid);
    RestRequest.Listener listener = new RestRequest.Listener() {

        @Override
        public void onResponse(JSONObject jsonObject) {
            AppLog.d(T.NOTIFS, "Register token action succeeded");
            try {
                String deviceID = jsonObject.getString("ID");
                if (deviceID == null) {
                    AppLog.e(T.NOTIFS, "Server response is missing of the device_id. Registration skipped!!");
                    return;
                }
                SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(ctx);
                SharedPreferences.Editor editor = settings.edit();
                editor.putString(WPCOM_PUSH_DEVICE_SERVER_ID, deviceID);
                editor.apply();
                AppLog.d(T.NOTIFS, "Server response OK. The device_id: " + deviceID);
            } catch (JSONException e1) {
                AppLog.e(T.NOTIFS, "Server response is NOT ok, registration skipped.", e1);
            }
        }
    };
    RestRequest.ErrorListener errorListener = new RestRequest.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError volleyError) {
            AppLog.e(T.NOTIFS, "Register token action failed", volleyError);
        }
    };
    WordPress.getRestClientUtils().post("/devices/new", contentStruct, null, listener, errorListener);
}
Also used : VolleyError(com.android.volley.VolleyError) SharedPreferences(android.content.SharedPreferences) HashMap(java.util.HashMap) JSONException(org.json.JSONException) RestRequest(com.wordpress.rest.RestRequest) JSONObject(org.json.JSONObject)

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