Search in sources :

Example 1 with BitmapRequestListener

use of com.androidnetworking.interfaces.BitmapRequestListener in project Fast-Android-Networking by amitshekhariitbhu.

the class MainActivity method loadImageDirect.

public void loadImageDirect(View view) {
    AndroidNetworking.get(URL_IMAGE).setTag("imageRequestTag").setPriority(Priority.MEDIUM).setImageScaleType(null).setBitmapMaxHeight(0).setBitmapMaxWidth(0).setBitmapConfig(Bitmap.Config.ARGB_8888).build().setAnalyticsListener(new AnalyticsListener() {

        @Override
        public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {
            Log.d(TAG, " timeTakenInMillis : " + timeTakenInMillis);
            Log.d(TAG, " bytesSent : " + bytesSent);
            Log.d(TAG, " bytesReceived : " + bytesReceived);
            Log.d(TAG, " isFromCache : " + isFromCache);
        }
    }).getAsBitmap(new BitmapRequestListener() {

        @Override
        public void onResponse(Bitmap response) {
            Log.d(TAG, "onResponse Bitmap");
            imageView.setImageBitmap(response);
        }

        @Override
        public void onError(ANError error) {
            if (error.getErrorCode() != 0) {
                // received ANError from server
                // error.getErrorCode() - the ANError code from server
                // error.getErrorBody() - the ANError body from server
                // error.getErrorDetail() - just a ANError detail
                Log.d(TAG, "onError errorCode : " + error.getErrorCode());
                Log.d(TAG, "onError errorBody : " + error.getErrorBody());
                Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
            } else {
                // error.getErrorDetail() : connectionError, parseError, requestCancelledError
                Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
            }
        }
    });
}
Also used : Bitmap(android.graphics.Bitmap) AnalyticsListener(com.androidnetworking.interfaces.AnalyticsListener) BitmapRequestListener(com.androidnetworking.interfaces.BitmapRequestListener) ANError(com.androidnetworking.error.ANError)

Example 2 with BitmapRequestListener

use of com.androidnetworking.interfaces.BitmapRequestListener 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)

Aggregations

Bitmap (android.graphics.Bitmap)2 ANError (com.androidnetworking.error.ANError)2 BitmapRequestListener (com.androidnetworking.interfaces.BitmapRequestListener)2 ANRequest (com.androidnetworking.common.ANRequest)1 AnalyticsListener (com.androidnetworking.interfaces.AnalyticsListener)1