use of com.android.volley.Response in project FastDev4Android by jiangqqlmj.
the class Fdv_StringRequest method post.
/**
* 根据地址和请求参数 发送POST请求
* @param url 地址服务器地址
* @param listener 数据加载回调接口
* @param params 请求参数
*/
public void post(String url, final Fdv_CallBackListener<String> listener, Map<String, String> params) {
StringRequest stringRequest = new StringRequest(Request.Method.POST, 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, params);
}
use of com.android.volley.Response in project AndroidNetworkDemo by dodocat.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
responseContentTextView = (TextView) findViewById(R.id.textViewResponseContent);
StringRequest request = new StringRequest(Request.Method.GET, "https://kyfw.12306.cn/otn/", new Response.Listener<String>() {
@Override
public void onResponse(String response) {
responseContentTextView.setText(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
responseContentTextView.setText(error.toString());
}
});
RequestManager.getInstance(this).addRequest(request, this);
}
use of com.android.volley.Response in project MaterialCalendar by Haoxiqiang.
the class TabooProxy method fetchJSContent.
public static void fetchJSContent() {
RequestQueue requestQueue = RQManager.getInstance().getRequestQueue();
for (int i = (SAVEYEAR - 10); i < (SAVEYEAR + 10); i++) {
final String datePrefix = String.valueOf(i);
StringRequest stringRequest = new StringRequest(Method.GET, FETCHURL + datePrefix + ".js", new Response.Listener<String>() {
@Override
public void onResponse(String response) {
String result = response.substring(response.indexOf("=") + 1, response.length() - 3) + "]";
try {
AssetJSONLoad.json2file(datePrefix + ".json", result);
} catch (IOException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
/* TODO Auto-generated method stub */
}
});
requestQueue.add(stringRequest);
}
requestQueue.start();
}
use of com.android.volley.Response in project MaterialCalendar by Haoxiqiang.
the class WeatherProxy method fetchWeatherContent.
public static void fetchWeatherContent(String dateParam) {
StringRequest stringRequest = new StringRequest(Method.GET, WE, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
Logger.json(response);
JSONObject result = new JSONObject(response);
insertWeather(result);
} catch (JSONException e) {
Logger.d(e.getMessage());
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
/* TODO Auto-generated method stub */
}
});
RequestQueue requestQueue = RQManager.getInstance().getRequestQueue();
requestQueue.add(stringRequest);
requestQueue.start();
}
use of com.android.volley.Response in project MVCHelper by LuckyJayce.
the class BooksVolleyDataSource method loadHomeGroup.
private RequestHandle loadHomeGroup(final ResponseSender<List<Book>> sender, final int page) throws Exception {
String url = "https://www.baidu.com";
Uri.Builder builder = Uri.parse(url).buildUpon();
builder.appendQueryParameter("page", String.valueOf(page));
StringRequest jsonObjRequest = new StringRequest(Request.Method.GET, builder.toString(), new Response.Listener<String>() {
@Override
public void onResponse(String response) {
List<Book> books = new ArrayList<Book>();
for (int i = 0; i < 30; i++) {
books.add(new Book("page" + page + " Java编程思想 " + i, 108.00d));
}
mPage = page;
sender.sendData(books);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
sender.sendError(error);
}
});
MyVolley.getRequestQueue().add(jsonObjRequest);
return new VolleyRequestHandle(jsonObjRequest);
}
Aggregations