Java 类com.android.volley.toolbox.GsonRequest 实例源码

项目:SimplifyReader2    文件:ImagesListInteractorImpl.java   
@Override
public void getCommonListData(final String requestTag, final int event_tag, String keywords, int page) {
    GsonRequest<ResponseImagesListEntity> gsonRequest = new GsonRequest<ResponseImagesListEntity>(
            UriHelper.getInstance().getImagesListUrl(keywords, page),
            null,
            new TypeToken<ResponseImagesListEntity>() {
            }.getType(),
            new Response.Listener<ResponseImagesListEntity>() {
                @Override
                public void onResponse(ResponseImagesListEntity response) {
                    loadedListener.onSuccess(event_tag, response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loadedListener.onException(error.getMessage());
                }
            }
    );

    gsonRequest.setShouldCache(true);
    gsonRequest.setTag(requestTag);

    VolleyHelper.getInstance().getRequestQueue().add(gsonRequest);
}
项目:SimplifyReader2    文件:GetVideoUserInteractorImpl.java   
@Override
public void getVideoUser(String requestTag, int user_id) {
    GsonRequest<VideosListUserEntity> gsonRequest = new GsonRequest<VideosListUserEntity>(
            UriHelper.getInstance().getVideoUserUrl(user_id),
            null,
            new TypeToken<VideosListUserEntity>() {
            }.getType(),
            new Response.Listener<VideosListUserEntity>() {
                @Override
                public void onResponse(VideosListUserEntity response) {
                    loadedListener.onSuccess(response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loadedListener.onException(error.getMessage());
                }
            }
    );

    gsonRequest.setShouldCache(true);
    gsonRequest.setTag(requestTag);

    VolleyHelper.getInstance().getRequestQueue().add(gsonRequest);
}
项目:SimplifyReader    文件:ImagesListInteractorImpl.java   
@Override
public void getCommonListData(final String requestTag, final int event_tag, String keywords, int page) {
    GsonRequest<ResponseImagesListEntity> gsonRequest = new GsonRequest<ResponseImagesListEntity>(
            UriHelper.getInstance().getImagesListUrl(keywords, page),
            null,
            new TypeToken<ResponseImagesListEntity>() {
            }.getType(),
            new Response.Listener<ResponseImagesListEntity>() {
                @Override
                public void onResponse(ResponseImagesListEntity response) {
                    loadedListener.onSuccess(event_tag, response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loadedListener.onException(error.getMessage());
                }
            }
    );

    gsonRequest.setShouldCache(true);
    gsonRequest.setTag(requestTag);

    VolleyHelper.getInstance().getRequestQueue().add(gsonRequest);
}
项目:SimplifyReader    文件:GetVideoUserInteractorImpl.java   
@Override
public void getVideoUser(String requestTag, int user_id) {
    GsonRequest<VideosListUserEntity> gsonRequest = new GsonRequest<VideosListUserEntity>(
            UriHelper.getInstance().getVideoUserUrl(user_id),
            null,
            new TypeToken<VideosListUserEntity>() {
            }.getType(),
            new Response.Listener<VideosListUserEntity>() {
                @Override
                public void onResponse(VideosListUserEntity response) {
                    loadedListener.onSuccess(response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loadedListener.onException(error.getMessage());
                }
            }
    );

    gsonRequest.setShouldCache(true);
    gsonRequest.setTag(requestTag);

    VolleyHelper.getInstance().getRequestQueue().add(gsonRequest);
}
项目:Whois    文件:RestHelper.java   
/**
 * Adds request with specified arguments to request queue
 * 
 * @param url - URL
 * @param method - Request method {@link Method}
 * @param clazz - Class for parameterization while decoding from json to specified type
 * @param headers - Additional headers which can provided in request
 * @param listener - Response listener which called when response successfully received  
 * @param errorListener - Response listener which called when something went wrong
 * @param requestData - Body to post with request
 */
private <T> void prepareRequest(
        String url,
        int method,
        Class<T> clazz,
        Map<String, String> headers,
        Listener<T> listener,
        ErrorListener errorListener,
        String requestData          ) {

    if(headers == null)
        headers = new HashMap<String, String>();

    GsonRequest<T> request = new GsonRequest<T>(
            url,
            method,
            clazz,
            headers,
            listener,
            errorListener != null ? errorListener : mDefaultListener);

    addToQueue(request);
}
项目:SimplifyReader2    文件:MusicsInteracotrImpl.java   
@Override
public void getMusicListData(String requestTag, String keywords, final int event_tag) {
    TLog.d(requestTag, UriHelper.getInstance().getDoubanPlayListUrl(keywords));
    GsonRequest<ResponseMusicsListentity> gsonRequest = new GsonRequest<ResponseMusicsListentity>(
            UriHelper.getInstance().getDoubanPlayListUrl(keywords),
            null,
            new TypeToken<ResponseMusicsListentity>() {
            }.getType(),
            new Response.Listener<ResponseMusicsListentity>() {
                @Override
                public void onResponse(ResponseMusicsListentity response) {
                    loadedListener.onSuccess(event_tag, response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loadedListener.onException(error.getMessage());
                }
            }
    );

    gsonRequest.setShouldCache(true);
    gsonRequest.setTag(requestTag);

    VolleyHelper.getInstance().getRequestQueue().add(gsonRequest);
}
项目:SimplifyReader2    文件:VideosListInteractorImpl.java   
@Override
public void getCommonListData(final String requestTag, final int event_tag, String keywords, int page) {
    TLog.d(requestTag, UriHelper.getInstance().getVideosListUrl(keywords, page));

    GsonRequest<ResponseVideosListEntity> gsonRequest = new GsonRequest<ResponseVideosListEntity>(
            UriHelper.getInstance().getVideosListUrl(keywords, page),
            null,
            new TypeToken<ResponseVideosListEntity>() {
            }.getType(),
            new Response.Listener<ResponseVideosListEntity>() {
                @Override
                public void onResponse(ResponseVideosListEntity response) {
                    loadedListener.onSuccess(event_tag, response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loadedListener.onException(error.getMessage());
                }
            }
    );

    gsonRequest.setShouldCache(true);
    gsonRequest.setTag(requestTag);

    VolleyHelper.getInstance().getRequestQueue().add(gsonRequest);
}
项目:SimplifyReader    文件:MusicsInteracotrImpl.java   
@Override
public void getMusicListData(String requestTag, String keywords, final int event_tag) {
    TLog.d(requestTag, UriHelper.getInstance().getDoubanPlayListUrl(keywords));
    GsonRequest<ResponseMusicsListentity> gsonRequest = new GsonRequest<ResponseMusicsListentity>(
            UriHelper.getInstance().getDoubanPlayListUrl(keywords),
            null,
            new TypeToken<ResponseMusicsListentity>() {
            }.getType(),
            new Response.Listener<ResponseMusicsListentity>() {
                @Override
                public void onResponse(ResponseMusicsListentity response) {
                    loadedListener.onSuccess(event_tag, response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loadedListener.onException(error.getMessage());
                }
            }
    );

    gsonRequest.setShouldCache(true);
    gsonRequest.setTag(requestTag);

    VolleyHelper.getInstance().getRequestQueue().add(gsonRequest);
}
项目:SimplifyReader    文件:VideosListInteractorImpl.java   
@Override
public void getCommonListData(final String requestTag, final int event_tag, String keywords, int page) {
    TLog.d(requestTag, UriHelper.getInstance().getVideosListUrl(keywords, page));

    GsonRequest<ResponseVideosListEntity> gsonRequest = new GsonRequest<ResponseVideosListEntity>(
            UriHelper.getInstance().getVideosListUrl(keywords, page),
            null,
            new TypeToken<ResponseVideosListEntity>() {
            }.getType(),
            new Response.Listener<ResponseVideosListEntity>() {
                @Override
                public void onResponse(ResponseVideosListEntity response) {
                    loadedListener.onSuccess(event_tag, response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loadedListener.onException(error.getMessage());
                }
            }
    );

    gsonRequest.setShouldCache(true);
    gsonRequest.setTag(requestTag);

    VolleyHelper.getInstance().getRequestQueue().add(gsonRequest);
}
项目:FastOmiai    文件:NetworkRequest.java   
public static <T> Request<T> get(String url, Class<T> clazz,
        Response.Listener<T> listener,
        Response.ErrorListener errorListener, boolean needUrlDecode) {

    RequestQueue queue = sInstance.getRequestQueue();
    GsonRequest<T> request = new GsonRequest<T>(url, clazz, listener,
            errorListener, needUrlDecode);
    request.setRetryPolicy(new DefaultRetryPolicy(5000, 5, 2.f));
    return queue.add(request);
}
项目:FastOmiai    文件:NetworkRequest.java   
public static <T> Request<T> post(String url,
        final Map<String, String> params, Class<T> clazz,
        Response.Listener<T> listener, Response.ErrorListener errorListener) {
    RequestQueue queue = sInstance.getRequestQueue();
    GsonRequest<T> request = new GsonRequest<T>(Request.Method.POST, url, clazz, listener,
            errorListener, false) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            return params;
        }
    };
    return queue.add(request);
}