use of com.android.volley.toolbox.StringRequest 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.toolbox.StringRequest 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);
}
use of com.android.volley.toolbox.StringRequest 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.toolbox.StringRequest 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.toolbox.StringRequest in project WordPress-Android by wordpress-mobile.
the class ReaderPostActions method bumpPageViewForPost.
public static void bumpPageViewForPost(SiteStore siteStore, ReaderPost post) {
if (post == null) {
return;
}
// don't bump stats for posts in sites the current user is an admin of, unless
// this is a private post since we count views for private posts from owner or member
SiteModel site = siteStore.getSiteBySiteId(post.blogId);
// site will be null here if the user is not the owner or a member of the site
if (site != null && !post.isPrivate) {
AppLog.d(T.READER, "skipped bump page view - user is admin");
return;
}
Response.Listener<String> listener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
AppLog.d(T.READER, "bump page view succeeded");
}
};
Response.ErrorListener errorListener = new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
AppLog.e(T.READER, volleyError);
AppLog.w(T.READER, "bump page view failed");
}
};
Request request = new StringRequest(Request.Method.GET, getTrackingPixelForPost(post), listener, errorListener) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
// call will fail without correct refer(r)er
Map<String, String> headers = new HashMap<>();
headers.put("Referer", TRACKING_REFERRER);
return headers;
}
};
WordPress.sRequestQueue.add(request);
}
Aggregations