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

项目:VolleySimple    文件:VolleySimple.java   
/**
 * @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);
}
项目:LuxVilla    文件:separadoraveiro.java   
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);
    }
项目:GitHub    文件:Fdv_JsonArrayRequest.java   
/**
 * 请求返回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);
}
项目:GitHub    文件:Fdv_JsonArrayRequest.java   
/**
 * 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);
}
项目:TrackIt-Android    文件:SearchActivity.java   
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);
}
项目:LuxVilla    文件:separadortodas.java   
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);
    }
项目:LuxVilla    文件:separadorbraga.java   
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);
    }
项目:LuxVilla    文件:separadorlikes.java   
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);
    }
项目:LuxVilla    文件:separadorporto.java   
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);
    }
项目:LuxVilla    文件:searchableactivity.java   
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);
    }
项目:band-up-android    文件:BandUpRepository.java   
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);
                    }
                }
        );
    }
项目:PGMacTips    文件:VolleyCalls.java   
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);
}
项目:Mood-On-Map    文件:MyMarker2.java   
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);
}
项目:Mood-On-Map    文件:NearMarkerActivity.java   
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);
}
项目:Mood-On-Map    文件:ShowInfoMarkerActivity.java   
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);
}
项目:Mood-On-Map    文件:ShowInfoMarkerActivity.java   
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);
}
项目:com-android    文件:PotmAdapter.java   
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);
    }
项目:com-android    文件:ComTracksAdapter.java   
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);
    }
项目:taiga-android    文件:HttpHelper.java   
public static JSONArray requestJsonArray(Context context, int method, Map<String, String> headers, String url,
                                         JSONObject params, Response.ErrorListener errorListener) {
  RequestFuture<JSONArray> future = RequestFuture.newFuture();
  final Map<String, String> reqHeaders = headers;
  JsonArrayRequest request = new JsonArrayRequest(method, url, params, future, future) {
    public Map<String, String> getHeaders() {
      return reqHeaders != null ? reqHeaders : new HashMap<String, String>();
    }
  };
  RequestManager.getInstance(context).addToRequestQueue(request);
  try {
    return future.get(REQUEST_TIMEOUT, TimeUnit.SECONDS);
  } catch (Exception e) {
    errorListener.onErrorResponse(new VolleyError(e));
  }
  return null;
}
项目:saga-android    文件:DownloadFragment.java   
private void getCharts() {

        mImageLoader = VolleySingleton.getInstance(getActivity()).getImageLoader();
        String url = "http://boundbytech.com/saga/get_charts.php";
        JsonArrayRequest request = new JsonArrayRequest(url,
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        mAdapter = new ChartsAdapter(response);
                        mRecyclerView.setAdapter(mAdapter);
                        mProgress.setVisibility(View.GONE);
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                VolleyLog.d(TAG, "Error: " + error.getMessage());
                mProgress.setVisibility(View.GONE);
            }
        });
        mQueue.add(request);

    }
项目:the-tech-frontier-app    文件:RecomendAPIImpl.java   
@Override
public void fetchRecomends(final DataListener<List<Recommend>> listener) {
    JsonArrayRequest request = new JsonArrayRequest(
            "http://www.devtf.cn/api/v1/?type=recommends",
            new Listener<JSONArray>() {

                @Override
                public void onResponse(JSONArray jsonArray) {
                    if (listener != null) {
                        // 解析结果
                        listener.onComplete(mRespHandler.parse(jsonArray));
                    }
                }
            }, null);
    performRequest(request);
}
项目:the-tech-frontier-app    文件:ArticleAPIImpl.java   
private void performRequest(final int page, int category,
        final DataListener<List<Article>> listener, ErrorListener errorListener) {
    JsonArrayRequest request = new JsonArrayRequest(
            "http://www.devtf.cn/api/v1/?type=articles&page=" + mPage + "&count=20&categoty="
                    + category,
            new Listener<JSONArray>() {

                @Override
                public void onResponse(JSONArray jsonArray) {
                    if (listener != null) {
                        // 解析结果
                        listener.onComplete(mRespHandler.parse(jsonArray));
                    }
                }
            }, errorListener);
    RequestQueueMgr.getRequestQueue().add(request);
}
项目:hex    文件:StoryCollectionService.java   
public List<Story> getStories(Collection collection) {
    String apiUrl = getUrlForCollection(collection);

    RequestFuture<JSONArray> future = RequestFuture.newFuture();
    JsonArrayRequest request = new JsonArrayRequest(mApiBaseUrl + apiUrl, future, future);
    request.setRetryPolicy(RetryPolicyFactory.build());

    mRequestQueue.add(request);

    try {
        JSONArray response = future.get();
        return FrontPageMarshaller.marshall(response);
    } catch (Exception e) {
        return null;
    }
}
项目:HTWDresden    文件:CheckUpdates.java   
/**
 * Studiengruppen aktualisieren
 */
private void updateStudyGroups() {
    VolleyDownloader.getInstance(context).addToRequestQueue(
            new JsonArrayRequest(
                    Const.internet.WEBSERVICE_URL_STUDYGROUPS,
                    new Response.Listener<JSONArray>() {
                        @Override
                        public void onResponse(final JSONArray response) {
                            final Realm realm = Realm.getDefaultInstance();
                            realm.beginTransaction();
                            realm.delete(StudyGroup.class);
                            realm.delete(StudyCourse.class);
                            realm.delete(StudyYear.class);
                            realm.createAllFromJson(StudyYear.class, response);
                            realm.commitTransaction();
                            realm.close();

                            PreferenceManager.getDefaultSharedPreferences(context)
                                    .edit()
                                    .putLong(Const.preferencesKey.PREFERENCES_MENSA_WEEK_LASTUPDATE, Calendar.getInstance().getTimeInMillis())
                                    .apply();
                        }
                    },
                    null)
    );
}
项目:android-promise-volley    文件:VolleyJsonPromise.java   
public static Promise<RArray> jsonArrayPromise(String url) {
    final DeferredObject<JSONArray> promise = new DeferredObject<JSONArray>();

    final JsonArrayRequest request = new JsonArrayRequest(url, new Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray jsonArray) {
            promise.success(jsonArray);
        }
    }, new ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            promise.failure(volleyError);
        }
    });

    return DeferredObject.successful(new RArray(request, promise));
}
项目:Shorcial    文件:Request.java   
public static void getPlayasCercanasTo (final Context ctx, final String direccion, final Double latitud, final Double longitud, final ProgressDialog pd){
    final String URL = Config.getURLServer(ctx) + "/playascercanas/" + latitud + "/" + longitud;
    JsonArrayRequest req = new JsonArrayRequest(URL, new Response.Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray response) {
            com.odc.beachodc.webservices.Response.responseGetPlayasCercanasTo(ctx, response, pd, direccion, latitud, longitud);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.e("Error: ", error.getMessage());
            pd.dismiss();
        }
    });

    // add the request object to the queue to be executed
    Config.addToRequestQueue(ctx, req);
}
项目:Shorcial    文件:Request.java   
public static void getPlayasByName (final Context ctx, final String name, final ProgressDialog pd){
    final String URL = Config.getURLServer(ctx) + "/playasbyname/" + name.replaceAll(" ", "%20");
    JsonArrayRequest req = new JsonArrayRequest(URL, new Response.Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray response) {
            com.odc.beachodc.webservices.Response.responseGetPlayasByName(ctx, response, pd, name);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.e("Error: ", error.getMessage());
            pd.dismiss();
        }
    });

    // add the request object to the queue to be executed
    Config.addToRequestQueue(ctx, req);
}
项目:Shorcial    文件:Request.java   
public static void getMensajesBotella (final Context ctx, String idPlaya, final ProgressDialog pd, final Intent intent){
    final String URL = Config.getURLServer(ctx)+"/mensajesplaya/"+idPlaya;
    ValidacionPlaya.mensajesBotella = new ArrayList<MensajeBotella>();
    JsonArrayRequest req = new JsonArrayRequest(URL, new Response.Listener<JSONArray> () {
        @Override
        public void onResponse(JSONArray response) {
            com.odc.beachodc.webservices.Response.responseGetMensajesBotella(ctx, response, pd, intent);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.e("Error: ", error.getMessage());
            ValidacionPlaya.cargadosMensajesPlaya=true;
            if (ValidacionPlaya.comprobarCargaPlaya(ctx, intent)){
                pd.dismiss();
            }
        }
    });

    // add the request object to the queue to be executed
    Config.addToRequestQueue(ctx, req);
}
项目:Shorcial    文件:Request.java   
public static void getImagenesPlaya (final Context ctx, String idPlaya, final ProgressDialog pd, final Intent intent){
    final String URL = Config.getURLServer(ctx)+"/imagenesplaya/"+idPlaya;
    ValidacionPlaya.imagenes = new ArrayList<Imagen>();
    JsonArrayRequest req = new JsonArrayRequest(URL, new Response.Listener<JSONArray> () {
        @Override
        public void onResponse(JSONArray response) {
            com.odc.beachodc.webservices.Response.responseGetImagenesPlaya(ctx, response, pd, intent);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.e("Error: ", error.getMessage());
            ValidacionPlaya.cargadaImagenes=true;
            if (ValidacionPlaya.comprobarCargaPlaya(ctx, intent)){
                pd.dismiss();
            }
        }
    });

    // add the request object to the queue to be executed
    Config.addToRequestQueue(ctx, req);
}
项目:Shorcial    文件:Request.java   
public static void getComentariosPlaya (final Context ctx, String idPlaya, final ProgressDialog pd, final Intent intent){
    final String URL = Config.getURLServer(ctx)+"/comentariosplaya/"+idPlaya;
    ValidacionPlaya.comentariosPlaya = new ArrayList<Comentario>();
    JsonArrayRequest req = new JsonArrayRequest(URL, new Response.Listener<JSONArray> () {
        @Override
        public void onResponse(JSONArray response) {
            com.odc.beachodc.webservices.Response.responseGetComentariosPlaya(ctx, response, pd, intent);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.e("Error: ", error.getMessage());
            ValidacionPlaya.cargadosComentarios=true;
            if (ValidacionPlaya.comprobarCargaPlaya(ctx, intent)){
                pd.dismiss();
            }
        }
    });

    // add the request object to the queue to be executed
    Config.addToRequestQueue(ctx, req);
}
项目:AndroidLinkup    文件:VolleyHelper.java   
/**
 * 加载JsonArray数据
 * 
 * @param url
 *            url地址
 * @param listener
 *            网络消息处理监听器
 */
public void getJsonArray(String url, final NetMsgListener<JSONArray> listener) {

    JsonArrayRequest jsonObjectRequest = new JsonArrayRequest(url, new Response.Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray response) {
            if (listener != null) {
                listener.onNetMsg(response);
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError e) {
            if (listener != null) {
                listener.onError(e);
            }
        }
    });
    requestQueue.add(jsonObjectRequest);
}
项目:list    文件:RequestMethods.java   
public void getCategories(final NetworkUtils.ResponseCallback callback) {
    if(!(isNetworkAvailable())){
        mMessageHelper.networkFailMessage();
        return;
    }

    RequestQueue queue = Volley.newRequestQueue(mContext);
    String url = ApiConstants.GET_CATEGORIES;

    JsonArrayRequest categoriesRequest = new JsonArrayRequest(url,
            new Response.Listener<JSONArray>() {
                @Override
                public void onResponse(JSONArray response) {
                    //Log.v(TAG, "> getCategories > onResponse: " + response);
                    callback.onSuccess(response);
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            //Log.d(TAG, "> getCategories > onErrorResponse: " + error.getMessage());
            callback.onFail(error);
        }
    });
    queue.add(categoriesRequest);
}
项目:list    文件:RequestMethods.java   
public void getRandomItems(final NetworkUtils.ResponseCallback callback) {
    if(!(isNetworkAvailable())){
        mMessageHelper.networkFailMessage();
        return;
    }

    RequestQueue queue = Volley.newRequestQueue(mContext);
    String url = ApiConstants.GET_RANDOM_ITEMS;

    JsonArrayRequest randomItemsRequest = new JsonArrayRequest(url,
            new Response.Listener<JSONArray>() {
                @Override
                public void onResponse(JSONArray response) {
                    callback.onSuccess(response);
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            callback.onFail(error);
        }
    });
    queue.add(randomItemsRequest);
}
项目:android-blog    文件:BlogListFragment.java   
private void getBlogPosts() {
  mRequestQueue.add(new JsonArrayRequest(getString(R.string.rest_base_url) + "/BlogPosts.json",
      new Response.Listener<JSONArray>() {
        @Override public void onResponse(JSONArray response) {
          try {
            blogPosts = mapper.readValue(response.toString(), new TypeReference<List<BlogPost>>() {});

            sort(blogPosts, sortAsc ? blogSorters.get(sortCol) : reverseOrder(blogSorters.get(sortCol)));
            blogListAdapter.setData(blogPosts);
            if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
              blogPostsListView.setSelection(selectedBlogIndex);
              listener.onClick(blogPosts.get(selectedBlogIndex));
            }
          } catch (Exception e) {
            throw new RuntimeException("Failed!", e);
          }
        }
      },
      new Response.ErrorListener() {
        @Override public void onErrorResponse(VolleyError error) {
          Log.e("ListBlogsActivity.onCreate()", "Volley failed to get BlogPosts! " + error.toString());
        }
      }
  ));
}
项目:GitHub    文件:JsonRequestCharsetTest.java   
@Test public void defaultCharsetJsonArray() throws Exception {
    // UTF-8 is default charset for JSON
    byte[] data = jsonArrayString().getBytes(Charset.forName("UTF-8"));
    NetworkResponse network = new NetworkResponse(data);
    JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
    Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);

    assertNotNull(arrayResponse);
    assertTrue(arrayResponse.isSuccess());
    assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
    assertEquals(COPY_VALUE, arrayResponse.result.getString(COPY_INDEX));
}
项目:GitHub    文件:JsonRequestCharsetTest.java   
@Test public void specifiedCharsetJsonArray() throws Exception {
    byte[] data = jsonArrayString().getBytes(Charset.forName("ISO-8859-2"));
    Map<String, String> headers = new HashMap<String, String>();
    headers.put("Content-Type", "application/json; charset=iso-8859-2");
    NetworkResponse network = new NetworkResponse(data, headers);
    JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
    Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);

    assertNotNull(arrayResponse);
    assertTrue(arrayResponse.isSuccess());
    assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
    // don't check the copyright symbol, ISO-8859-2 doesn't have it, but it has Czech characters
}
项目:GitHub    文件:JsonRequestCharsetTest.java   
@Test public void defaultCharsetJsonArray() throws Exception {
    // UTF-8 is default charset for JSON
    byte[] data = jsonArrayString().getBytes(Charset.forName("UTF-8"));
    NetworkResponse network = new NetworkResponse(data);
    JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
    Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);

    assertNotNull(arrayResponse);
    assertTrue(arrayResponse.isSuccess());
    assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
    assertEquals(COPY_VALUE, arrayResponse.result.getString(COPY_INDEX));
}
项目:GitHub    文件:JsonRequestCharsetTest.java   
@Test public void specifiedCharsetJsonArray() throws Exception {
    byte[] data = jsonArrayString().getBytes(Charset.forName("ISO-8859-2"));
    Map<String, String> headers = new HashMap<String, String>();
    headers.put("Content-Type", "application/json; charset=iso-8859-2");
    NetworkResponse network = new NetworkResponse(data, headers);
    JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
    Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);

    assertNotNull(arrayResponse);
    assertTrue(arrayResponse.isSuccess());
    assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
    // don't check the copyright symbol, ISO-8859-2 doesn't have it, but it has Czech characters
}
项目:Codeforces    文件:JsonRequestCharsetTest.java   
@Test public void defaultCharsetJsonArray() throws Exception {
    // UTF-8 is default charset for JSON
    byte[] data = jsonArrayString().getBytes(Charset.forName("UTF-8"));
    NetworkResponse network = new NetworkResponse(data);
    JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
    Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);

    assertNotNull(arrayResponse);
    assertTrue(arrayResponse.isSuccess());
    assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
    assertEquals(COPY_VALUE, arrayResponse.result.getString(COPY_INDEX));
}
项目:Codeforces    文件:JsonRequestCharsetTest.java   
@Test public void specifiedCharsetJsonArray() throws Exception {
    byte[] data = jsonArrayString().getBytes(Charset.forName("ISO-8859-2"));
    Map<String, String> headers = new HashMap<String, String>();
    headers.put("Content-Type", "application/json; charset=iso-8859-2");
    NetworkResponse network = new NetworkResponse(data, headers);
    JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
    Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);

    assertNotNull(arrayResponse);
    assertTrue(arrayResponse.isSuccess());
    assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
    // don't check the copyright symbol, ISO-8859-2 doesn't have it, but it has Czech characters
}