Search in sources :

Example 31 with VolleyError

use of com.android.volley.VolleyError in project SwipeToLoadLayout by Aspsine.

the class TwitterScrollViewFragment method onRefresh.

@Override
public void onRefresh() {
    GsonRequest request = new GsonRequest<SectionCharacters>(Constants.API.CHARACTERS, SectionCharacters.class, new Response.Listener<SectionCharacters>() {

        @Override
        public void onResponse(SectionCharacters sectionCharacters) {
            List<Character> characters = sectionCharacters.getCharacters();
            for (int i = 0; i < characters.size(); i++) {
                String img = characters.get(i).getAvatar();
                if (i < ivArray.length) {
                    Picasso.with(getActivity()).load(img).into(ivArray[i]);
                }
            }
            swipeToLoadLayout.setRefreshing(false);
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError volleyError) {
            swipeToLoadLayout.setRefreshing(false);
            volleyError.printStackTrace();
        }
    });
    App.getRequestQueue().add(request).setTag(TAG);
}
Also used : Response(com.android.volley.Response) SectionCharacters(com.aspsine.swipetoloadlayout.demo.model.SectionCharacters) VolleyError(com.android.volley.VolleyError) GsonRequest(com.android.volley.toolbox.GsonRequest) List(java.util.List)

Example 32 with VolleyError

use of com.android.volley.VolleyError in project SwipeToLoadLayout by Aspsine.

the class GoogleStyleFragment method onLoadMore.

@Override
public void onLoadMore() {
    GsonRequest request = new GsonRequest<SectionCharacters>(Constants.API.CHARACTERS, SectionCharacters.class, new Response.Listener<SectionCharacters>() {

        @Override
        public void onResponse(final SectionCharacters characters) {
            // here, I use post delay to show more animation, you don't have to.
            swipeToLoadLayout.postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (mPageNum < 3) {
                        mPageNum++;
                        mAdapter.append(characters.getSections().subList(mPageNum, mPageNum + 1));
                    } else {
                        Toast.makeText(getContext(), "Done", Toast.LENGTH_SHORT).show();
                    }
                    swipeToLoadLayout.setLoadingMore(false);
                }
            }, 2000);
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError volleyError) {
            swipeToLoadLayout.setLoadingMore(false);
            volleyError.printStackTrace();
        }
    });
    App.getRequestQueue().add(request).setTag(TAG + "loadmore" + mType);
}
Also used : Response(com.android.volley.Response) SectionCharacters(com.aspsine.swipetoloadlayout.demo.model.SectionCharacters) VolleyError(com.android.volley.VolleyError) GsonRequest(com.android.volley.toolbox.GsonRequest)

Example 33 with VolleyError

use of com.android.volley.VolleyError in project SwipeToLoadLayout by Aspsine.

the class TwitterGridViewFragment method onLoadMore.

@Override
public void onLoadMore() {
    GsonRequest request = new GsonRequest<SectionCharacters>(Constants.API.CHARACTERS, SectionCharacters.class, new Response.Listener<SectionCharacters>() {

        @Override
        public void onResponse(SectionCharacters characters) {
            if (mPageNum < 3) {
                mPageNum++;
                mAdapter.append(characters.getSections().get(mPageNum).getCharacters());
            } else {
                Toast.makeText(getContext(), "Done", Toast.LENGTH_SHORT).show();
            }
            swipeToLoadLayout.setLoadingMore(false);
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError volleyError) {
            swipeToLoadLayout.setLoadingMore(false);
            volleyError.printStackTrace();
        }
    });
    App.getRequestQueue().add(request).setTag(TAG + "loadmore");
}
Also used : Response(com.android.volley.Response) SectionCharacters(com.aspsine.swipetoloadlayout.demo.model.SectionCharacters) VolleyError(com.android.volley.VolleyError) GsonRequest(com.android.volley.toolbox.GsonRequest)

Example 34 with VolleyError

use of com.android.volley.VolleyError 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)

Example 35 with VolleyError

use of com.android.volley.VolleyError 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)

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