Search in sources :

Example 6 with GsonRequest

use of com.android.volley.toolbox.GsonRequest in project SwipeToLoadLayout by Aspsine.

the class TwitterRecyclerFragment 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().subList(mPageNum, mPageNum + 1));
            } 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" + 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 7 with GsonRequest

use of com.android.volley.toolbox.GsonRequest in project SwipeToLoadLayout by Aspsine.

the class TwitterRecyclerFragment 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 characters) {
            mPageNum = 0;
            mAdapter.setList(characters.getCharacters(), characters.getSections().subList(0, mPageNum + 1));
            swipeToLoadLayout.setRefreshing(false);
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError volleyError) {
            swipeToLoadLayout.setRefreshing(false);
            volleyError.printStackTrace();
        }
    });
    App.getRequestQueue().add(request).setTag(TAG + "refresh" + 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 8 with GsonRequest

use of com.android.volley.toolbox.GsonRequest in project SwipeToLoadLayout by Aspsine.

the class GoogleStyleFragment method onRefresh.

@Override
public void onRefresh() {
    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() {
                    mPageNum = 0;
                    mAdapter.setList(characters.getCharacters(), characters.getSections().subList(0, mPageNum + 1));
                    swipeToLoadLayout.setRefreshing(false);
                }
            }, 3000);
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError volleyError) {
            swipeToLoadLayout.setRefreshing(false);
            volleyError.printStackTrace();
        }
    });
    App.getRequestQueue().add(request).setTag(TAG + "refresh" + 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 9 with GsonRequest

use of com.android.volley.toolbox.GsonRequest in project SwipeToLoadLayout by Aspsine.

the class TwitterGridViewFragment 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 characters) {
            mAdapter.setList(characters.getSections().get(0).getCharacters());
            swipeToLoadLayout.setRefreshing(false);
            mPageNum = 0;
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError volleyError) {
            swipeToLoadLayout.setRefreshing(false);
            volleyError.printStackTrace();
        }
    });
    App.getRequestQueue().add(request).setTag(TAG + "refresh");
}
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)

Aggregations

Response (com.android.volley.Response)9 VolleyError (com.android.volley.VolleyError)9 GsonRequest (com.android.volley.toolbox.GsonRequest)9 SectionCharacters (com.aspsine.swipetoloadlayout.demo.model.SectionCharacters)8 Bitmap (android.graphics.Bitmap)1 ImageLoader (com.android.volley.toolbox.ImageLoader)1 ImageRequest (com.android.volley.toolbox.ImageRequest)1 StringRequest (com.android.volley.toolbox.StringRequest)1 LoopViewPagerAdapter (com.aspsine.swipetoloadlayout.demo.adapter.LoopViewPagerAdapter)1 UpdateBean (com.chinaztt.fda.entity.UpdateBean)1 Fdv_ImageCache (com.chinaztt.fdv.Fdv_ImageCache)1 Fdv_JsonObjectRequest (com.chinaztt.fdv.Fdv_JsonObjectRequest)1 Fdv_StringRequest (com.chinaztt.fdv.Fdv_StringRequest)1 Gson (com.google.gson.Gson)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Click (org.androidannotations.annotations.Click)1 JSONObject (org.json.JSONObject)1