Search in sources :

Example 6 with Response

use of com.android.volley.Response in project FastDev4Android by jiangqqlmj.

the class Fdv_JsonArrayRequest method post.

/**
     * POST请求返回JSONArray对象
     * @param url   请求地址
     * @param listener   请求数据返回回调接口
     * @param params   POST请求参数
     */
public void post(String url, final Fdv_CallBackListener<JSONArray> listener, Map<String, String> params) {
    JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.POST, url, null, new Response.Listener<JSONArray>() {

        @Override
        public void onResponse(JSONArray response) {
            if (listener != null) {
                listener.onSuccessResponse(response);
            }
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            if (listener != null) {
                listener.onErrorResponse(error);
            }
        }
    });
    addRequest(jsonArrayRequest, params);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) JsonArrayRequest(com.android.volley.toolbox.JsonArrayRequest) JSONArray(org.json.JSONArray)

Example 7 with Response

use of com.android.volley.Response in project FastDev4Android by jiangqqlmj.

the class Fdv_JsonObjectRequest method get.

/**
     * 请求返回JSONObject对象 Get请求 无参数,或者get请求的参数直接拼接在URL上面
     * @param url   请求地址
     * @param listener  数据回调接口
     */
public void get(String url, final Fdv_CallBackListener<JSONObject> listener) {
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject response) {
            if (listener != null) {
                listener.onSuccessResponse(response);
            }
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            if (listener != null) {
                listener.onErrorResponse(error);
            }
        }
    });
    addRequest(jsonObjectRequest);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) JSONObject(org.json.JSONObject) JsonObjectRequest(com.android.volley.toolbox.JsonObjectRequest)

Example 8 with Response

use of com.android.volley.Response in project FastDev4Android by jiangqqlmj.

the class Fdv_JsonObjectRequest method post.

/**
     * 发送POST请求, 返回JSONObject对象数据
     * @param url    请求地址
     * @param listener  数据返回回调接口
     * @param params   POST请求参数
     */
public void post(String url, final Fdv_CallBackListener<JSONObject> listener, Map<String, String> params) {
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url, null, new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject response) {
            if (listener != null) {
                listener.onSuccessResponse(response);
            }
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            if (listener != null) {
                listener.onErrorResponse(error);
            }
        }
    });
    addRequest(jsonObjectRequest, params);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) JSONObject(org.json.JSONObject) JsonObjectRequest(com.android.volley.toolbox.JsonObjectRequest)

Example 9 with Response

use of com.android.volley.Response in project FastDev4Android by jiangqqlmj.

the class Fdv_StringRequest method get.

/**
     * 普通文本等信息 Get请求 无参数,或者get请求的参数直接拼接在URL上面
     * @param url  请求的地址
     * @param listener  数据请求返回接口回调
     */
public void get(String url, final Fdv_CallBackListener<String> listener) {
    StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
            if (listener != null) {
                listener.onSuccessResponse(response);
            }
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            if (listener != null) {
                listener.onErrorResponse(error);
            }
        }
    });
    addRequest(stringRequest);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) StringRequest(com.android.volley.toolbox.StringRequest)

Example 10 with Response

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

the class RendezVousFragment method getRendeVousByManager.

private void getRendeVousByManager() {
    CustomRequestArray jsonReq = new CustomRequestArray(Request.Method.GET, GET_RDV_BY_TEACHER, null, new Response.Listener<JSONArray>() {

        @Override
        public void onResponse(JSONArray response) {
            if (GRID_LAYOUT) {
                recyclerViewRendeVous.setLayoutManager(new GridLayoutManager(getActivity(), 2));
            } else {
                recyclerViewRendeVous.setLayoutManager(new LinearLayoutManager(getActivity()));
            }
            recyclerViewRendeVous.setHasFixedSize(true);
            //Use this now
            recyclerViewRendeVous.addItemDecoration(new MaterialViewPagerHeaderDecorator());
        //recyclerViewRendeVous.setAdapter(new TeachersAdapter(response,(TeachersAdapter.AdapterInterface) RendezVousActivity.this));
        }
    }, 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) GridLayoutManager(android.support.v7.widget.GridLayoutManager) JSONArray(org.json.JSONArray) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MaterialViewPagerHeaderDecorator(com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)

Aggregations

Response (com.android.volley.Response)110 VolleyError (com.android.volley.VolleyError)108 JSONObject (org.json.JSONObject)80 JsonObjectRequest (com.android.volley.toolbox.JsonObjectRequest)60 RequestQueue (com.android.volley.RequestQueue)58 HashMap (java.util.HashMap)57 JSONException (org.json.JSONException)57 User (model.User)49 JSONArray (org.json.JSONArray)29 CustomRequestArray (dz.easy.androidclient.Util.CustomRequestArray)18 Context (android.content.Context)17 Toast (android.widget.Toast)17 StringRequest (com.android.volley.toolbox.StringRequest)14 TextView (android.widget.TextView)9 CustomRequest (dz.easy.androidclient.Util.CustomRequest)9 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 Intent (android.content.Intent)6 GridLayoutManager (android.support.v7.widget.GridLayoutManager)6 JsonArrayRequest (com.android.volley.toolbox.JsonArrayRequest)6 MaterialViewPagerHeaderDecorator (com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)5