use of com.android.volley.VolleyError in project FastDev4Android by jiangqqlmj.
the class Fdv_JsonObjectRequest method post.
/**
* 发送POST请求, 返回JSONObject对象数据
* @param url 请求地址
* @param listener 数据返回回调接口
* @param params POST请求参数
*/
public void post(String url, final Fdv_CallBackListener<JSONObject> listener, Map<String, String> params) {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
if (listener != null) {
listener.onSuccessResponse(response);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (listener != null) {
listener.onErrorResponse(error);
}
}
});
addRequest(jsonObjectRequest, params);
}
use of com.android.volley.VolleyError in project FastDev4Android by jiangqqlmj.
the class Fdv_StringRequest method get.
/**
* 普通文本等信息 Get请求 无参数,或者get请求的参数直接拼接在URL上面
* @param url 请求的地址
* @param listener 数据请求返回接口回调
*/
public void get(String url, final Fdv_CallBackListener<String> listener) {
StringRequest stringRequest = new StringRequest(Request.Method.GET, 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);
}
use of com.android.volley.VolleyError in project FastDev4Android by jiangqqlmj.
the class BasicNetwork method attemptRetryOnException.
/**
* Attempts to prepare the request for a retry. If there are no more attempts remaining in the
* request's retry policy, a timeout exception is thrown.
* @param request The request to use.
*/
private static void attemptRetryOnException(String logPrefix, Request<?> request, VolleyError exception) throws VolleyError {
RetryPolicy retryPolicy = request.getRetryPolicy();
int oldTimeout = request.getTimeoutMs();
try {
retryPolicy.retry(exception);
} catch (VolleyError e) {
request.addMarker(String.format("%s-timeout-giveup [timeout=%s]", logPrefix, oldTimeout));
throw e;
}
request.addMarker(String.format("%s-retry [timeout=%s]", logPrefix, oldTimeout));
}
use of com.android.volley.VolleyError in project RxJava-Android-Samples by kaushikgopal.
the class VolleyDemoFragment method startVolleyRequest.
private void startVolleyRequest() {
DisposableSubscriber<JSONObject> d = new DisposableSubscriber<JSONObject>() {
@Override
public void onNext(JSONObject jsonObject) {
Log.e(TAG, "onNext " + jsonObject.toString());
_log("onNext " + jsonObject.toString());
}
@Override
public void onError(Throwable e) {
VolleyError cause = (VolleyError) e.getCause();
String s = new String(cause.networkResponse.data, Charset.forName("UTF-8"));
Log.e(TAG, s);
Log.e(TAG, cause.toString());
_log("onError " + s);
}
@Override
public void onComplete() {
Log.e(TAG, "onCompleted");
Timber.d("----- onCompleted");
_log("onCompleted ");
}
};
newGetRouteData().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(d);
_disposables.add(d);
}
use of com.android.volley.VolleyError in project 9GAG by stormzhang.
the class ImageCacheManager method getImageListener.
public static ImageLoader.ImageListener getImageListener(final ImageView view, final Drawable defaultImageDrawable, final Drawable errorImageDrawable) {
return new ImageLoader.ImageListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (errorImageDrawable != null) {
view.setImageDrawable(errorImageDrawable);
}
}
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
if (response.getBitmap() != null) {
if (!isImmediate && defaultImageDrawable != null) {
TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[] { defaultImageDrawable, new BitmapDrawable(App.getContext().getResources(), response.getBitmap()) });
transitionDrawable.setCrossFadeEnabled(true);
view.setImageDrawable(transitionDrawable);
transitionDrawable.startTransition(100);
} else {
view.setImageBitmap(response.getBitmap());
}
} else if (defaultImageDrawable != null) {
view.setImageDrawable(defaultImageDrawable);
}
}
};
}
Aggregations