use of im.amomo.volley.sample.BaseRequest in project OkVolley by googolmo.
the class RequestFragment method post.
private void post() {
BaseRequest request = new BaseRequest(Request.Method.POST, "http://192.168.2.19:5000/test1", new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
Toast.makeText(getActivity(), jsonObject.toString(), Toast.LENGTH_SHORT).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (error instanceof ServerError) {
Toast.makeText(getActivity(), new String(((ServerError) error).networkResponse.data, Charset.defaultCharset()), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
// request.form("text", "test " + SystemClock.elapsedRealtime());
request.setTag("request");
OkVolley.getInstance().getRequestQueue().add(request);
}
use of im.amomo.volley.sample.BaseRequest in project OkVolley by googolmo.
the class RequestFragment method load.
private void load() {
OkRequest request = new BaseRequest(Request.Method.GET, "https://api.douban.com/v2/user/googolmo", new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
Toast.makeText(getActivity(), jsonObject.toString(), Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), jsonObject.optString("name"), Toast.LENGTH_SHORT).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
request.setTag("request");
OkVolley.getInstance().getRequestQueue().add(request);
}
Aggregations