Search in sources :

Example 11 with ANRequest

use of com.androidnetworking.common.ANRequest in project Fast-Android-Networking by amitshekhariitbhu.

the class ANImageLoader method makeImageRequest.

protected ANRequest makeImageRequest(String requestUrl, int maxWidth, int maxHeight, ImageView.ScaleType scaleType, final String cacheKey) {
    ANRequest ANRequest = AndroidNetworking.get(requestUrl).setTag("ImageRequestTag").setBitmapMaxHeight(maxHeight).setBitmapMaxWidth(maxWidth).setImageScaleType(scaleType).setBitmapConfig(Bitmap.Config.RGB_565).setBitmapOptions(mBitmapOptions).build();
    ANRequest.getAsBitmap(new BitmapRequestListener() {

        @Override
        public void onResponse(Bitmap response) {
            onGetImageSuccess(cacheKey, response);
        }

        @Override
        public void onError(ANError anError) {
            onGetImageError(cacheKey, anError);
        }
    });
    return ANRequest;
}
Also used : ANRequest(com.androidnetworking.common.ANRequest) Bitmap(android.graphics.Bitmap) BitmapRequestListener(com.androidnetworking.interfaces.BitmapRequestListener) ANError(com.androidnetworking.error.ANError)

Example 12 with ANRequest

use of com.androidnetworking.common.ANRequest in project Fast-Android-Networking by amitshekhariitbhu.

the class ANRequestQueue method cancel.

private void cancel(RequestFilter filter, boolean forceCancel) {
    synchronized (mCurrentRequests) {
        try {
            for (Iterator<ANRequest> iterator = mCurrentRequests.iterator(); iterator.hasNext(); ) {
                ANRequest request = iterator.next();
                if (filter.apply(request)) {
                    request.cancel(forceCancel);
                    if (request.isCanceled()) {
                        request.destroy();
                        iterator.remove();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : ANRequest(com.androidnetworking.common.ANRequest)

Example 13 with ANRequest

use of com.androidnetworking.common.ANRequest in project Fast-Android-Networking by amitshekhariitbhu.

the class ANRequestQueue method cancelAll.

public void cancelAll(boolean forceCancel) {
    synchronized (mCurrentRequests) {
        try {
            for (Iterator<ANRequest> iterator = mCurrentRequests.iterator(); iterator.hasNext(); ) {
                ANRequest request = iterator.next();
                request.cancel(forceCancel);
                if (request.isCanceled()) {
                    request.destroy();
                    iterator.remove();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : ANRequest(com.androidnetworking.common.ANRequest)

Aggregations

ANRequest (com.androidnetworking.common.ANRequest)13 ANError (com.androidnetworking.error.ANError)6 Response (okhttp3.Response)6 IOException (java.io.IOException)5 AnalyticsListener (com.androidnetworking.interfaces.AnalyticsListener)4 JSONObject (org.json.JSONObject)4 ANResponse (com.androidnetworking.common.ANResponse)3 Request (okhttp3.Request)3 Bitmap (android.graphics.Bitmap)2 DownloadProgressListener (com.androidnetworking.interfaces.DownloadProgressListener)2 User (com.networking.model.User)2 List (java.util.List)2 RequestBody (okhttp3.RequestBody)2 MockResponse (okhttp3.mockwebserver.MockResponse)2 JSONException (org.json.JSONException)2 HttpLoggingInterceptor (com.androidnetworking.interceptors.HttpLoggingInterceptor)1 BitmapRequestListener (com.androidnetworking.interfaces.BitmapRequestListener)1 JSONObjectRequestListener (com.androidnetworking.interfaces.JSONObjectRequestListener)1 OkHttpResponseAndJSONObjectRequestListener (com.androidnetworking.interfaces.OkHttpResponseAndJSONObjectRequestListener)1 File (java.io.File)1