当前位置: 首页>>代码示例>>Java>>正文


Java JsonArrayRequest类代码示例

本文整理汇总了Java中com.android.volley.toolbox.JsonArrayRequest的典型用法代码示例。如果您正苦于以下问题:Java JsonArrayRequest类的具体用法?Java JsonArrayRequest怎么用?Java JsonArrayRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonArrayRequest类属于com.android.volley.toolbox包,在下文中一共展示了JsonArrayRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: placeJsonArrayRequest

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
/**
 * @param apiTag         tag to uniquely distinguish Volley requests. Null is allowed
 * @param url            URL to fetch the string at
 * @param httpMethod     the request method to use (GET or POST)
 * @param params         A {@link JSONArray} to post with the request. Null is allowed and
 *                       indicates no parameters will be posted along with request.
 * @param headers        optional Http headers
 * @param serverCallback Listener to receive the String response
 */
public void placeJsonArrayRequest(@Nullable final String apiTag, String url, int httpMethod, @Nullable JSONArray params, final @Nullable HashMap<String, String> headers, final ServerCallback serverCallback) {

    Request request = new JsonArrayRequest(httpMethod, url, params, new Response.Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray response) {
            serverCallback.onAPIResponse(apiTag, response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            serverCallback.onErrorResponse(apiTag, error);
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            return headers != null ? headers : super.getHeaders();
        }
    };

    request.setRetryPolicy(retryPolicy);

    addToRequestQueue(request);
}
 
开发者ID:ferozbaig96,项目名称:VolleySimple,代码行数:33,代码来源:VolleySimple.java

示例2: sendjsonRequest

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
private void sendjsonRequest(){

        JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(Request.Method.GET,"http://brunoferreira.esy.es/serverdata.php",null, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {
                casas=parsejsonResponse(response);
                adaptador.setCasas(casas);
                progressBar.setVisibility(View.GONE);
                swipeRefreshLayout.setVisibility(View.VISIBLE);

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                progressBar.setVisibility(View.GONE);
                swipeRefreshLayout.setVisibility(View.VISIBLE);
                Snackbar.make(recyclerViewtodas,"Falha ao ligar ao servidor",Snackbar.LENGTH_LONG).show();

            }
        });

        requestQueue.add(jsonArrayRequest);
    }
 
开发者ID:brunomassa,项目名称:LuxVilla,代码行数:24,代码来源:separadoraveiro.java

示例3: get

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
/**
 * 请求返回JSONArray对象 Get请求 无参数,或者get请求的参数直接拼接在URL上面
 * @param url  请求地址
 * @param listener  数据返回回调接口
 */
public void get(String url, final Fdv_CallBackListener<JSONArray> listener){
    JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(Request.Method.GET, 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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:Fdv_JsonArrayRequest.java

示例4: post

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:Fdv_JsonArrayRequest.java

示例5: loadSearchSuggestions

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
private void loadSearchSuggestions(final String query) {
    String showName = query.replaceAll("\\s", "+");
    RequestQueue requestQueue = VolleySingleton.getInstance().getRequestQueue();
    JsonArrayRequest req = new JsonArrayRequest(
            API.TV_MAZE_SEARCH + showName,
            new Response.Listener<JSONArray>() {
                @Override
                public void onResponse(JSONArray response) {
                    List<SearchSuggestions> searchSuggestions = new ArrayList<>();
                    JSONObject object;
                    try {
                        for (int j = 0; j < response.length() && searchSuggestions.size() < 5; j++) {
                            object = response.getJSONObject(j).getJSONObject("show");
                            SearchSuggestions suggestion = new SearchSuggestions(object.getString("name"));
                            if (!searchSuggestions.contains(suggestion)) {
                                searchSuggestions.add(suggestion);
                            }
                        }
                    } catch (JSONException e) {
                        //Log.e("JSON exception", e.getMessage());
                    }
                    if (searchView.isSearchBarFocused()) {
                        searchView.swapSuggestions(searchSuggestions);
                    }
                    searchView.hideProgress();
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    searchView.hideProgress();
                }
            });
    req.setRetryPolicy(new DefaultRetryPolicy(
            5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    requestQueue.add(req);
}
 
开发者ID:chashmeetsingh,项目名称:TrackIt-Android,代码行数:39,代码来源:SearchActivity.java

示例6: sendjsonRequest

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
private void sendjsonRequest(){

        JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(Request.Method.GET,"http://brunoferreira.esy.es/serverdata.php",null, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {
                casas=parsejsonResponse(response);
                adaptador.setCasas(casas);
                progressBar.setVisibility(View.GONE);
                swipeRefreshLayout.setVisibility(View.VISIBLE);
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                progressBar.setVisibility(View.GONE);
                swipeRefreshLayout.setVisibility(View.VISIBLE);
                Snackbar.make(recyclerViewtodas,"Falha ao ligar ao servidor",Snackbar.LENGTH_LONG).show();

            }
        });

        requestQueue.add(jsonArrayRequest);
    }
 
开发者ID:brunomassa,项目名称:LuxVilla,代码行数:23,代码来源:separadorporto.java

示例7: sendjsonRequest

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
private void sendjsonRequest(){

        JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(Request.Method.GET,"http://brunoferreira.esy.es/serverdata.php",null, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {
                casas=parsejsonResponse(response);
                adaptador.setCasas(casas);

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Snackbar.make(rvc1,"Falha ao ligar ao servidor",Snackbar.LENGTH_LONG).show();

            }
        });

        requestQueue.add(jsonArrayRequest);
    }
 
开发者ID:brunomassa,项目名称:LuxVilla,代码行数:20,代码来源:searchableactivity.java

示例8: createArrayRequest

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
private JsonArrayRequest createArrayRequest(int httpMethod, String url, JSONArray data, final BandUpResponseListener responseListener, final BandUpErrorListener errorListener) {

        return new JsonArrayRequest(
                httpMethod,
                url,
                data,
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        responseListener.onBandUpResponse(response);
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        errorListener.onBandUpErrorResponse(error);
                    }
                }
        );
    }
 
开发者ID:BandUp,项目名称:band-up-android,代码行数:21,代码来源:BandUpRepository.java

示例9: startJsonArrayRequest

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
public void startJsonArrayRequest(Context context){
    String url = "http://my-json-feed";

    JsonArrayRequest jsObjRequest = new JsonArrayRequest
            (Request.Method.GET, url, null, new Response.Listener<JSONArray>() {

                @Override
                public void onResponse(JSONArray response) {
                    String str = response.toString();
                    //Do stuff with string here.
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    //Do stuff with response here
                }
            });

    // Access the RequestQueue through your singleton class.
    VolleySingleton.getInstance(context).addToRequestQueue(jsObjRequest);
}
 
开发者ID:PGMacDesign,项目名称:PGMacTips,代码行数:23,代码来源:VolleyCalls.java

示例10: getData

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
protected void getData(final VolleyResponseListener listener){
    Bundle extras = getIntent().getExtras();
    String android_id = extras.getString("android_id");
    String url = "http://afnecors.altervista.org/android2016/api.php/markers?id_device="+android_id;

    JsonArrayRequest jsObjRequest = new JsonArrayRequest
            (Request.Method.GET, url, null, new Response.Listener<JSONArray>() {

                @Override
                public void onResponse(JSONArray response) {
                    listener.onResponse(response);
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    // TODO Auto-generated method stub

                }
            });

    // Access the RequestQueue through your singleton class.
    MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
}
 
开发者ID:afnecors,项目名称:Mood-On-Map,代码行数:25,代码来源:MyMarker2.java

示例11: getData

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
protected void getData(final VolleyResponseListener listener){
    String url = "http://afnecors.altervista.org/android2016/api.php/markers";

    JsonArrayRequest jsObjRequest = new JsonArrayRequest
            (Request.Method.GET, url, null, new Response.Listener<JSONArray>() {

                @Override
                public void onResponse(JSONArray response) {
                    listener.onResponse(response);
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    // TODO Auto-generated method stub

                }
            });

    // Access the RequestQueue through your singleton class.
    MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
}
 
开发者ID:afnecors,项目名称:Mood-On-Map,代码行数:23,代码来源:NearMarkerActivity.java

示例12: getData

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
protected void getData(final VolleyResponseListener listener){
    Bundle extras = getIntent().getExtras();
    final int id_marker = extras.getInt("id_marker");
    String url = "http://afnecors.altervista.org/android2016/api.php/markers/"+id_marker;

    JsonArrayRequest jsObjRequest = new JsonArrayRequest
            (Request.Method.GET, url, null, new Response.Listener<JSONArray>() {

                @Override
                public void onResponse(JSONArray response) {
                    listener.onResponse(response);
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    // TODO Auto-generated method stub

                }
            });

    // Access the RequestQueue through your singleton class.
    MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
}
 
开发者ID:afnecors,项目名称:Mood-On-Map,代码行数:25,代码来源:ShowInfoMarkerActivity.java

示例13: deleteData

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
protected void deleteData(int id){
    String url = "http://afnecors.altervista.org/android2016/api.php/markers/"+id;

    JsonArrayRequest jsObjRequest = new JsonArrayRequest
            (Request.Method.DELETE, url, null, new Response.Listener<JSONArray>() {

                @Override
                public void onResponse(JSONArray response) {
                    listener.onResponse(response);
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    // TODO Auto-generated method stub

                }
            });

    // Access the RequestQueue through your singleton class.
    MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
}
 
开发者ID:afnecors,项目名称:Mood-On-Map,代码行数:23,代码来源:ShowInfoMarkerActivity.java

示例14: PotmAdapter

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
public PotmAdapter(Context mContext) {
        super();
        this.mContext = mContext;
        RequestQueue requestQueue = Volley.newRequestQueue(mContext);
        JsonArrayRequest trackRequest = new JsonArrayRequest(Request.Method.GET, com_url + "getPOTMs", null, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {
                try {
                    for (int i = 0; i < response.length(); i++) {
                        potms.add(new Potm(response.getJSONObject(i)));
                    }
                    notifyDataSetChanged();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
//                Couldn't fetch data
            }
        });
        requestQueue.add(trackRequest);
    }
 
开发者ID:Circle-Of-Music-Makers,项目名称:com-android,代码行数:25,代码来源:PotmAdapter.java

示例15: ComTracksAdapter

import com.android.volley.toolbox.JsonArrayRequest; //导入依赖的package包/类
public ComTracksAdapter(Context mContext) {
        super();
        this.mContext = mContext;
        mTrackList = new ArrayList<>();
        RequestQueue requestQueue = Volley.newRequestQueue(mContext);
        JsonArrayRequest trackRequest = new JsonArrayRequest(Request.Method.GET, com_url + "getTracks", null, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {
                try {
                    for (int i = 0; i < response.length(); i++) {
                        mTrackList.add(new ComTrack(response.getJSONObject(i)));
                    }
                    notifyDataSetChanged();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
//                Couldn't fetch data
            }
        });
        requestQueue.add(trackRequest);
    }
 
开发者ID:Circle-Of-Music-Makers,项目名称:com-android,代码行数:26,代码来源:ComTracksAdapter.java


注:本文中的com.android.volley.toolbox.JsonArrayRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。